Difference between running on Qt 5.15 and Qt 6.0. Size of QML elements in UI. Why?
-
Hello all!
I am trying to move onto Qt 6.0 and got stacked on size of QML objects. It's different when I am running it Qt 5.15 and Qt 6.0.
Why is that? Right side of the image Qt 5.15 left is Qt 6.0. Why it's smaller? Is there any special parameter for HiDPI? Or any kind of scaling proportion coefficient?
What am I missing in Qt 6.0?
Code sample published here
All of it looks like every size a little smaller - size of QML Rectangle, QML Text.
Why it's happening? -
It's happening even on simple default Qt/QML application
// System includes import QtQuick 2.15 import QtQuick.Controls 2.15 // Application includes // Application ApplicationWindow { property string pText: qsTr("Hello world!"); id: oApplicationWindow; // flags: Qt.Window | Qt.MaximizeUsingFullscreenGeometryHint; width: 640; height: 480; visible: true; title: oApplicationWindow.pText; color: "white"; Text { id: oTestText; text: oApplicationWindow.pText; font.pixelSize: 30; anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter; } Rectangle { id: oTestRectangleLeft; width: 30; height: 30; color: "red"; anchors.top: parent.top; anchors.topMargin: 100; anchors.left: parent.left; } Rectangle { id: oTestRectangleRight; width: 30; height: 30; color: "red"; anchors.top: parent.top; anchors.topMargin: 100; anchors.right: parent.right; } }
The result is:
I understand that is somehow related to actual pixel size and HiDPI but I haven't found any info about it yet. Is there any?
-
The simple investigation showing different value of screen properties on one device.
In QML:Component.onCompleted: { console.log("Screen.pixelDensity:",Screen.pixelDensity) console.log("Screen.devicePixelRatio:",Screen.devicePixelRatio) }
Result on Qt 6.0
qml: Screen.pixelDensity: 8.55762414463817 qml: Screen.devicePixelRatio: 2.25
Result on Qt 5.15
qml: Screen.pixelDensity: 6.417322834645669 qml: Screen.devicePixelRatio: 3
One code, one device, but different values of the screen properties. Why?
Is it Qt bug?The same result when run it from Xcode directly on one physical device.
Xcode and Qt 6.0:2021-04-12 10:01:38.950778+0300 Qt60Size[485:312485] [qml] Screen.pixelDensity: 8.557889784573582 2021-04-12 10:01:38.950908+0300 Qt60Size[485:312485] [qml] Screen.devicePixelRatio: 1.5
Xcode and Qt 5.15:
2021-04-12 10:04:25.550715+0300 Qt60Size[493:313567] [qml] Screen.pixelDensity: 6.417322834645669 2021-04-12 10:04:25.550828+0300 Qt60Size[493:313567] [qml] Screen.devicePixelRatio: 2
-
Yes, either a bug or a bug fix in Qt 6 :-) Check the bugtracker, it should be there somewhere.