Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Detect "is_on_top" in QML StackView. How?



  • Hello all!
    I need to detect that the QML Object is on top of StackView. Is there any way to do it?
    For example:

    StackView {
    
    	id: oStackView;
    	width: parent.width;
    	height: parent.height;
    
    	Component.onCompleted: {
    		oStackView.push(oScreenLogin);
    	}
    
    	Component {id: oScreenLogin; SScreenLogin {}}
    	Component {id: oScreenSearch; SScreenSearch {}}
    	Component {id: oScreenTest; SScreenTest {}}
    }
    

    I need to detect inside of oScreenLogin that it is on top of StackView. How to do it?



  • Solution found. Issue closed.
    Inside of SScreenLogin:

    property string pObjectName: "SScreenLogin";
    
    id: oRoot;
    objectName: oRoot.pObjectName;
    

    And inside of JS script:

    if (oStackView.currentItem.objectName == oRoot.pObjectName) {
    	On top
    } else {
    	Not on top
    }
    

Log in to reply