Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize the rotation of Qt window

Shulou Source: shulou.com Published: 2022-06-01 13:28:54 09月22日 Update

This article introduces the relevant knowledge of "how to achieve Qt window rotation". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Modify the display process of the main window in main.cpp. Rotate is the main window class:

Int main (int argc, char * argv [])

{

QApplication a (argc, argv)

Rotate w / WT / main window

/ *

* rotate the main window

, /

QGraphicsScene * scene = new QGraphicsScene

QGraphicsProxyWidget * gpw = scene- > addWidget

Gpw- > setRotation (90); / / rotate 90 degrees

QGraphicsView * view = new QGraphicsView (scene)

View- > showFullScreen (); / / full screen display

Return a.exec ()

}

After being added, it is shown in figure 94.1:

The child window uses the "this" pointer to specify that the parent window loads all project interfaces into QGraphicsScene. The time code for creating the child window object is as follows:

Void Rotate::showOpenFile ()

{

Gf = new getfile (this); / / the child window calls scene

Gf- > show ()

Connect (gf,SIGNAL (OK_signal ()), this,SLOT (showText (); / / receive the signal from the child window

}

After completion, as shown in figure 94.2:

The effect of the main window is shown in figure 94.3:

Click on the toolbar to open the file, pop up the child window, and select the file name in the child window.

Displays the contents of the file:

When running on the development board, the window should be resized according to the screen size. Using this method, you must put all the windows in the project into Scene in order to achieve the effect of rotation.

This is the end of the content of "how to rotate Qt window". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Content documents such as pictures effects more knowledge process practicality learning next signals dilemmas size actual objects dimensions screens tools toolbars engineering Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux MySQL Huawei Docker