Reputation: 460
Let's say I have two overlapping QML Widgets, two Buttons for example. In normal Qt, there is QWidget.raise_()
and QWidget::raise()
to do this. Is there something similar in QML?
Upvotes: 1
Views: 577
Reputation: 243897
To show an Item over another then it is enough that the property z
is greater than the other.
import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow {
id: window
width: 640
height: 480
visible: true
Rectangle {
id: rect1
width: 0.7 * parent.width
height: 0.6 * parent.height
color: "red"
}
Rectangle {
id: rect2
width: 0.7 * parent.width
height: 0.6 * parent.height
anchors.right: parent.right
anchors.bottom: parent.bottom
color: "blue"
z: 1
}
Timer {
interval: 500
running: true
repeat: true
onTriggered: {
if (rect1.z == 0) {
rect1.z = 1;
rect2.z = 0;
} else {
rect1.z = 0;
rect2.z = 1;
}
}
}
}
Upvotes: 3