Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.2.6
-
Windows 10 Pro 21H2, MSVC 2019 x64
Description
There is a bug in Qt 6.3.2 and QT 6.2.6 where windows can be shown with wrong size calculations. This bug is not present in Qt 6.4.0; it would be great to backport the fix to Qt 6.2 LTS.
Code
// main.qml import QtQuick.Controls.Material ApplicationWindow { width: 640 height: 480 visible: true ConfigurationWindow { id: config } Button { text: "Pop Up" onClicked: config.show() } }
// ConfigurationWindow.qml import QtQuick.Controls.Material ApplicationWindow { id: popup width: 360 height: 240 /* // WORKAROUND: "Overriding" Window.show() like this forces the correct calculations function show() { popup.visible = true popup.width += 1 popup.width -= 1 } */ Button { text: "I am right-aligned" anchors.right: parent.right } onVisibleChanged: { if (popup.visible) console.log("Popup size:", popup.width, 'x', popup.height) } }
Steps to reproduce
- Set up 2 screens, where the primary screen has 125% scaling and the secondary screen has 100% scaling
- Build and run the attached project
- Drag the main window to the secondary screen
- Click "Pop Up"
- Close the popup window
- Click "Pop Up" again
Outcomes for Qt 6.2/6.3 (wrong)
Console output:
qml: Popup size: 360 x 240 qml: Popup size: 288 x 192
The pop-up window looks like right-align-wrong1.png the first time, then r_ight-align-wrong2.png_ the second time.
Outcomes for Qt 6.4 (correct)
Console output:
qml: Popup size: 360 x 240 qml: Popup size: 360 x 240
The pop-up window looks like right-align-correct.png both times.
Workaround
After show()-ing the popup window, increment then decrement the window width. This seems to force the correct calculations.