In reading this thread, I am puzzled as to how the OP was able to use QResizeEvent to determine that the screen had been rotated. QResizeEvent contains absolutely no screen orientation information at all, just the old and new sizes of the *widget* to which it applies. If the OP was simply making the assumption that the orientation had changed by comparing width and height of the new and old rects, then that is a flawed interpretation of the event.
I think I would be surprised if the resize event was sent at all after an orientation change, because the *widget* has not in fact undergone a change in size.
I also fail to see why a connection can't be made to the QScreen::orientationChanged() signal from anywhere:
QScreen * pScreen
= QGuiApplication
::primaryScreen();
connect( pScreen, SIGNAL( orientationChanged( int ) ), this, SLOT( onScreenOrientationChanged( int ) ) );
QScreen * pScreen = QGuiApplication::primaryScreen();
connect( pScreen, SIGNAL( orientationChanged( int ) ), this, SLOT( onScreenOrientationChanged( int ) ) );
To copy to clipboard, switch view to plain text mode
where, of course, you have to write the slot code in your widget class to do whatever is required. Also note this important factoid from the docs:
void QScreen::setOrientationUpdateMask(Qt::ScreenOrient ations mask)
Sets the orientations that the application is interested in receiving updates for in conjunction with this screen.
For example, to receive orientation() updates and thus have orientationChanged() signals being emitted for LandscapeOrientation and InvertedLandscapeOrientation, call setOrientationUpdateMask() with mask set to Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation.
The default, 0, means no orientationChanged() signals are fired.
(emphasis mine).
If I were to make a guess, if the application sets this flag at the outset, there would be no need to handle orientationChanged() signals at all. The app would probably automatically rotate everything on its own. That the default setting is to ignore orientation changes implies that rotating the screen would have no effect on the app's orientation.
Bookmarks