Some trouble with high DPI
-
Using Qt 5.15.2, I created a Qt Quick 2.0 application. The app is contained in a borderless non-resizeable window, and is planned to support the high DPI features. However I have some trouble, especially when I have several monitors with different DPI settings.
There are several situations.
1 - I open my borderless window onto a 120 dpi monitor:
Then I move it onto a 96 dpi monitor:
As you can see, the window size changes, but its content isn't resized
2- I add a frame to my window, and I open it onto a 120 dpi monitor:
Now I move it onto a 96 dpi monitor:
Then I move it back to the 120 dpi monitor:
This time, the content is resized too large in relation to my window.
I also get strange logs I cannot figure out, like the following:
QWindowsWindow::setGeometry: Unable to set geometry 400x728+3574+161 (frame: 416x767+3566+130) on CommandListForm_QMLTYPE_194/"" on "\.\DISPLAY1". Resulting geometry: 504x920+3574+161 (frame: 520x959+3566+130) margins: 8, 31, 8, 8) - qwindowswindow.cpp:1891, void __cdecl QWindowsWindow::setGeometry(const class QRect &)As Qt is supposed to support high DPI features, what am I doing wrong?
NOTE below is the window code for the first situation:
// common properties id: awMainForm objectName: "awMainForm" width: 602 height: 728 minimumWidth: 602 minimumHeight: 728 maximumWidth: 602 maximumHeight: 728 flags: (Qt.Window | Qt.FramelessWindowHint) visible: true
and for the second:
// common properties id: awMainForm objectName: "awMainForm" width: 602 height: 728 minimumWidth: 602 minimumHeight: 728 maximumWidth: 602 maximumHeight: 728 flags: Qt.Window visible: true
-
I finally found a solution which seems to work in my case. I added the Qt.MSWindowsFixedSizeDialogHint window flag, which seems to fix the issue.
So below is the modified code:
ApplicationWindow { // common properties id: awMainForm width: 602 height: 728 flags: Qt.Window | Qt.FramelessWindowHint | Qt.MSWindowsFixedSizeDialogHint visible: true // form content isn't relevant ... }