Priority: P3: Somewhat important
Affects Version/s: 5.15
Fix Version/s: None
Component/s: GUI: High-DPI
QScreen from QMainWindow isn't correct after the WM_DPICHANGED message.
As a result the application is displaying at the incorrect DPI.
MonitorA: 1920x1080 at 100% DIP (Main)
MonitorB: 1920x1080 at 125% DIP
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.
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.
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.