[SOLVED]using Timer on previewing another QML with Loader element



  • @
    //this is QML1

    import QtQuick 1.0

    Rectangle {
    width: 360
    height: 360

    Loader {
    id:mainLoader
    }
    MouseArea {
    id: mouse_area1
    x: 250
    y: 302
    width: 78
    height: 39
    drag.minimumY: -1000
    drag.minimumX: -1000
    drag.maximumY: 1000
    drag.maximumX: 1000
    onClicked: { mainLoader.source = "main2.qml";
    //when i click this it will load my QML2

        }
    }
    
    Text {
        id: text1
        x: 278
        y: 315
        width: 80
        height: 20
        text: "Click"
        font.pixelSize: 12
    }
    

    }
    @

    @
    //this is QML2

    import QtQuick 1.0

    Rectangle {
    width: 360
    height: 360
    color: "#dd1a1a"

    }
    @

    if i click the mousearea it will load QML2,
    I have a question, can i use a timer element on previewing QML2 everytime the mousearea is triggered?
    And after a few minutes of previewing QML2, it will automatically exit and return to QML1,

    Is this possible? Can you please help me


  • Moderators

    Try something like:

    @
    Loader {
    id: mainLoader
    }

    Timer {
    id: timer
    interval: 60000 // 1 minute (or whatever)

        onTriggered: {
             mainLoader.source = ""
        }
    

    }

    MouseArea {
    id: mouse_area1
    x: 250
    y: 302
    width: 78
    height: 39
    drag.minimumY: -1000
    drag.minimumX: -1000
    drag.maximumY: 1000
    drag.maximumX: 1000
    onClicked: {
    timer.start();
    mainLoader.source = "main2.qml";
    //when i click this it will load my QML2

        }
    }
    

    @



  • Thanks!! ^ ^


Log in to reply
 

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