Show on top of all
Unsolved
QML and Qt Quick
-
-
@LeLev :
Here are some code snippets.
I have a label. When the label is clicked I want to open a new rectangle to show some infos here. I set the z-property of the rectangle to 100. But this rectangle is not shown on top of all other elements. It is only on top of that label, but below a lot of other labels and other things...Label { ... MouseArea { id: mouseId anchors.fill: parent onPressAndHold: { } onClicked: { rectId.visible = true } } Rectangle { id: rectId color: Style.widgetBoxColor width: 600 height: 600 z: 100 visible: false Image { id: imageId anchors.fill: parent } MouseArea { id: rectMouseId anchors.fill: parent onPressAndHold: { } onClicked: { rectId.visible = false } } } }
-
@MHermann in your exemple there are no 'other labels and other things' , there is only 1 rectangle, i addes one more rectangle with z-property unset, your rectangle will be on top if z > other z. Test this
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 2.0Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")Label { text: "Testlab" z:5 MouseArea { id: mouseId anchors.fill: parent onPressAndHold: { } onClicked: { rectId.visible = true } } Rectangle { id: rectId color: "red" width: 600 height: 600 z: 4 visible: false anchors.centerIn: parent Image { id: imageId anchors.fill: parent } MouseArea { id: rectMouseId anchors.fill: parent onPressAndHold: { } onClicked: { rectId.visible = false } } } } Rectangle{ id:autherRec height: 75 width: height*2 color: "gray" // z:3 }
}