Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
None
-
5.15
-
None
Description
QScreen from QMainWindow isn't correct after the WM_DPICHANGED message.
As a result the application is displaying at the incorrect DPI.
User Config:
Two monitors.
MonitorA: 1920x1080 at 100% DPI (Main)
MonitorB: 1920x1080 at 125% DPI
Steps:
MonitorA & MonitorB are connected with the application running on MonitorA.
User then disconnects MonitorA, the application is auto moved to MonitorB, so MonitorB is now the main.
User reconnects MonitorA, the application is moved back to MonitorA but the DPI isn't updated.
The issue is that QMainWindow is still using the QScreen from MonitorB and never updated to the QScreen for MonitorA, testapp, screenshots and message log attached.
Debugging info:
From debugging this, the issues appears to be that Qt is ignoring the WM_DPICHANGED messages, this is because Qt will ignore all calls to the method "QWindowsWindow::checkForScreenChanged" if "QWindowsScreenManager::isSingleScreen()" is true.
The second screen is only added when Qt gets the message WM_SETTINGCHANGE, and by that time we already missed the WM_DPICHANGED messages.
It looks like Qt should be adding the second screen on the WM_DISPLAYCHANGE message, but in the method "QWindowsScreenManager::handleDisplayChange" Qt will only checks if the resolution has changed, and in this case the resolution is the same on the two monitors.
Workaround:
Drag the the app across to the other monitor and back, the DPI will be updated on the WM_DPICHANGED message as Qt now knows about the second monitor.
From testing with just a Qt test app the application will fix it's self on move/resize, but if Qt::FramelessWindowHint is set, the only option is to restart the app.