Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.9.1
-
f1ec81b543fe1d5090acff298e24faf10a7bac63 (qtbase/5.9, 26.9.2017, 5.9.3)
Description
The best way to make a dialog (with e.g only labels and buttons) fixed size is
layout()->setSizeConstraint(QLayout::SetFixedSize);
However in a multi screen environment moving such a dialog from one screen to another (slowly) in high DPI mode may cause a lot of flickering and the dialog may end up with controls placed completely wrong.
Steps to reproduce (at least the flickering part)
- Have two screens with very diffent device pixel ratio (2.0 vs 1.0). In my example I have two 4k screens with one set to 175 and the other to 125. (Monitor 1 (scale 125) is set to be on the right side)
- Compile attached example
- OR modify the example: examples\widgets\mainwindows\mainwindow )
int main(int argc, char **argv) (main.cpp)
as the first line of the function (before QApplication ctor) insert
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
and before mainWin.show() add
mainWin.layout()->setSizeConstraint(QLayout::SetFixedSize);
// Somewhere add #include <QLayout>
- Finally slowly move the dialog from one screen to the other. (On faster moves the risk of any flicking (and dialog mess) is reduced)
Reason:
When the dialog moves to a new screen (in high DPI mode) Qt tries to change the window size in QGuiApplicationPrivate::processGeometryChangeEvent. However the size constraint will ensure that the dialog quickly afterwards will resize again. This new (layout constaint) size often causes the to end up being mainly on the previous Screen, so the dialog is nearly instantly moved backed to the screen it came from. Here it is again resized (twice). This will again cause the dialog end up on the screen Qt originally tried to change to.
Only a top left point check (which seems to be held on most or all resizes) prevents infinite screen changes, but a new small mouse movement will instantly repeat this resize the circus.
Somehow all these size changes can cause the controls to be completely wrong. (Though other examples may reproduce better than this mainwindow example)
This issue can be reproduced on Windows and may exist on Linux (not tested). It does not happen on Mac.
Attachments
Issue Links
- is duplicated by
-
QTBUG-63463 Windows: Problems when moving dialog across screens with different scalings
- Open
- relates to
-
QTBUG-61821 setFixedSize(sizeHint()); glitch on dialog move
- Reported
- resulted in
-
QTBUG-72504 Moving QML window between screens with different DPI breaks QML layout and size
- Closed