Show on top of all



  • Hi!

    How can I show a rectangle on top of all elements, also the elements that were created later.
    I tried to use the z-property. But that didn't work. There are still a lot elements on top of the rectangle.
    Any suggestions?

    Kind regards,
    MHermann



  • @MHermann Hello,
    Could you show your code ? Z must do the job



  • @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.0

    Window {
    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
    
    }
    

    }


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.