I am using QML (Qt Quick) in order to set-up the GUI of an app and I am having weird behaviors.
Here is my initial piece of code:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
Rectangle {
id: rectangle1
color: palette.grey
ColumnLayout
{
id: columnLayout1
Label
{
id: label1
text: qsTr("Target")
font.pointSize: 22
}
ProgressBar
{
id: progressBar1
value: 0.5
}
} }
... which gives layout:
Then I anchor the centers:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
Rectangle
{
id: rectangle1
color: palette.grey
ColumnLayout
{
id: columnLayout1
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Label
{
id: label1
text: qsTr("Target")
font.pointSize: 22
}
ProgressBar
{
id: progressBar1
value: 0.5
}
}
}
No problem here, I get:
Now things go wrong when I rotate the slider:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
Rectangle
{
id: rectangle1
color: palette.grey
ColumnLayout
{
id: columnLayout1
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Label
{
id: label1
text: qsTr("Target")
font.pointSize: 22
}
ProgressBar
{
id: progressBar1
rotation: 90
value: 0.5
}
}
}
And here I was expecting Qt to rotate the slider and use the rotated slider to compute the layout, but it is not what happens. Actually the layout seems to be computed with the slider unrotated then only the slider is rotated. This ends up with a layout which is no longer a column:
This looks a bit buggy, no? Or am I doing something wrong?
Now another problem occurs when I wrap the slider in an Item (I was actually playing with Items to see if I could find a workaround):
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
Rectangle
{
id: rectangle1
color: palette.grey
ColumnLayout
{
id: columnLayout1
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Label
{
id: label1
text: qsTr("Target")
font.pointSize: 22
}
Item
{
ProgressBar
{
id: progressBar1
value: 0.5
}
}
}
}
And in this case what I get is a slider above the label (although it is defined after it in the code):
This also looks weird to me... Anybody has an idea of what I did wrong?
Please note that the screen shots are captured from Designer but running the program leads to the exact same problems.
Kind regards,
Antoine Rennuit.