Layouts with screen orientation bug?
Solved
QML and Qt Quick
-
I have a problem with GridLayout in ColumnLayout. When screen orientation changes to portrait I set columns to 1 and on landscape to 2
Console log shows correct columns setting but visually it is the oposite.
If I change ColumnLayout to Column it works as it should.I am using Android QT 6.5.0 Clang armeabi-v7a
Minimal example to reproduce the problem:
import QtQuick import QtQuick.Window import QtQuick.Layouts Window { id:glavni width: 640 height: 480 visible: true title: qsTr("Hello World") ColumnLayout { anchors.fill: parent Rectangle { Layout.fillWidth: true Layout.preferredHeight: 100 color: "blue" } Rectangle { Layout.fillWidth: true Layout.preferredHeight: 100 color: "red" } GridLayout { id:postavitev Layout.fillWidth: true Layout.fillHeight: true columns: (Screen.primaryOrientation===Qt.PortraitOrientation)?1:2 onColumnsChanged: { console.log("Columns:"+columns) } Rectangle { Layout.fillHeight: true Layout.fillWidth: true color:"yellow" } Rectangle { Layout.fillHeight: true Layout.fillWidth: true color:"gray" } } } }
Is this a bug or am I doing something wrong?
Thanks, Aleš
-