Priority: Not Evaluated
Affects Version/s: 5.12.5, 5.13.1, 5.14.0 Beta2
Fix Version/s: None
Environment:macOS Mojave 10.14.6 on a MacBook Pro 2019
Qt 5.13.1 (also tried latest 5.14.0-beta2)
I had a weird issue in my app and I finally tracked it down to what I believe is a bug/inconsistency in Qt:
1. Start your Qt based GUI app.
2. User changes the screen resolution of primary display via system preferences panel on macOS
3. App's list of QScreens now have the old geometry and never learn about the new screen resolution. The QScreen no longer agrees with what the Cocoa NSScreen.screens returns(Cocoa is right, Qt's QScreens are wrong and have the old geometry).
I did some digging and basically if macOS sends your app a display
"Shape Changed" callback (which can happen as the result of the user reconfiguring the screen's resolution in the control panel [see screenshot]), it appears Qt's QScreens still have the old "shape" (geometry).
If you query the geometry of the QScreen classes returned from qApp->screens() or qApp->primaryScreen(), you get the old geometry. The only way to fix this is to quit the app and restart it and then it picks up the new geometry... but should the user decide to change screen resolution again on the primary screen - Qt won't get the new geometry for the qscreen.
This affects some of my code that relies on the QScreen geometry for decisions it makes.
- Start the app in 1400x900
- Go to System Preferences -> Displays -> Change the display resolution (they call it scaling, but it's really a logical resolution change).
- Application gets the event, Qt windows draw ok, etc
- However, if your app queries the QScreens, they all have the old geometry. This list of screens disagrees now with what Cocoa's NSScreen.screens returnes.
I have attached a log from the debug console in my app. It basically illustrates how Cocoa has a list of screens and they are correct, and Qt still has the old screens.