Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED]using Timer on previewing another QML with Loader element
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jr_jags
    wrote on last edited by
    #1

    @
    //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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      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

          }
      }
      

      @

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jr_jags
        wrote on last edited by
        #3

        Thanks!! ^ ^

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved