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. how we can create 2 second delay or wait in qml?
Forum Updated to NodeBB v4.3 + New Features

how we can create 2 second delay or wait in qml?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 26.3k Views 1 Watching
  • 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.
  • stackprogramerS Offline
    stackprogramerS Offline
    stackprogramer
    wrote on last edited by stackprogramer
    #1

    i don't want use import QtTest 1.0,
    i want before that my method executes ,it wait a little and start to execute,thanks for reply. in another way can anyone guide me

    1 Reply Last reply
    0
    • T Offline
      T Offline
      t3685
      wrote on last edited by
      #2

      You can't use a Timer?

      stackprogramerS 1 Reply Last reply
      2
      • T t3685

        You can't use a Timer?

        stackprogramerS Offline
        stackprogramerS Offline
        stackprogramer
        wrote on last edited by
        #3

        @t3685 said:

        You can't use a Timer?

        oh,you are right thanks for reply............

        1 Reply Last reply
        0
        • T Offline
          T Offline
          t3685
          wrote on last edited by
          #4

          Sometimes things are so obvious we can't even see them😃

          1 Reply Last reply
          0
          • stackprogramerS Offline
            stackprogramerS Offline
            stackprogramer
            wrote on last edited by stackprogramer
            #5

            with guidance my dear friend @t3685
            i create a some delay function

            function delay(duration) { // In milliseconds
                var timeStart = new Date().getTime();
            
                while (new Date().getTime() - timeStart < duration) {
                    // Do nothing
                }
            
                // Duration has passed
            }
            

            or another way

            function delay(delayTime) {
                timer = new Timer();
                timer.interval = delayTime;
                timer.repeat = false;
                timer.start();
            }
            
            1 Reply Last reply
            0
            • K Offline
              K Offline
              kloffy
              wrote on last edited by
              #6

              Are you looking for something like this?

              Timer {
                  id: timer
                  running: false
                  repeat: false
              
                  property var callback
              
                  onTriggered: callback()
              }
              
              function setTimeout(callback, delay)
              {
                  if (timer.running) {
                      console.error("nested calls to setTimeout are not supported!");
                      return;
                  }
                  timer.callback = callback;
                  // note: an interval of 0 is directly triggered, so add a little padding
                  timer.interval = delay + 1;
                  timer.running = true;
              }
              
              1 Reply Last reply
              1
              • stackprogramerS Offline
                stackprogramerS Offline
                stackprogramer
                wrote on last edited by stackprogramer
                #7

                my problem is solved before thanks very much

                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