navigation using page loader element



  • Hello everyone i want to develope a code to navigate qml pages (eg. next and back).
    below is my test code.
    issue i am facing is once i go to "next" and "back", i again cant go to "next". along with my element on first qml is visible by setting property and cant controll mouse area "onclicked" as required.

    
    /// main.qml
    
    import QtQuick 1.1
    
    Rectangle {
        width: 360
        height: 360
    
        Loader {
            id : loader1
        }
    
        Rectangle {
            id : button1
            width: 100
            height: 50
            radius: 10
            focus: true
            color: "steelblue"
            anchors.horizontalCenter: parent.horizontalCenter
            y: 100
    
    
        Text {
            text: qsTr("next")
            anchors.centerIn: parent
        }
    
        MouseArea {
            anchors.fill: parent
            onClicked: {
                loader1.source="test.qml"
            }
        }
        }
    }
    
    /// test.qml
    
    import QtQuick 1.1
    
    Rectangle {
        width: 360
        height: 360
        color:  "red"
    
        Loader {
            id : loader1
        }
    
        Rectangle {
            width: 100
            height: 50
            radius: 10
            color: "steelblue"
            anchors.horizontalCenter: parent.horizontalCenter
            y: 200
    
        Text {
            text: qsTr("back")
            anchors.centerIn: parent
        }
    
        MouseArea {
            anchors.fill: parent
            onClicked: {
                loader1.source="main.qml"
            }
        }
        }
    }
    
    

  • Moderators

    @Anas_Deshmukh I guess the components are overlapping and hiding each other.



  • @p3c0 thanks for reply, Yes i was sure abt it, my elements getting overlapped (stil ltrying to fix it with adjustments). now my doubt is when loader load new page i think i messed up with "focus" property, ie. onMouseClicked, text input feild , tab navigation, and keyboard input key detect (unable to get input right now). Is there is any way when i load new page previous page properly hide and i can focus on element as my need. i read abt "binding" but little confuse on same approach.


  • Moderators

    @Anas_Deshmukh Are you stuck with Qt Quick 1.x ? Can you move to latest version ?



  • @p3c0 No, i cant move to qt5,my code is part of opensource developement.(Qt 4.8.6)


  • Moderators

    @Anas_Deshmukh said in navigation using page loader element:

    Is there is any way when i load new page previous page properly hide and i can focus on element as my need. i read abt "binding" but little confuse on same approach.

    Perhaps you can bind the visible property of pages with Loader's status property i.e when status = Loader.Ready hide other one.
    Or it could be as trivial as hiding a page when you click a button to load other page.



  • Hi all,
    this issue is solve by adjusting 'focus' property and 'forceActiveFocus' in every loaded qml form.
    I use timer and onTriggered signal help me adjust focus in every loaded qml form.


Log in to reply
 

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