Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qtimer::singleshot slot completed
Qt 6.11 is out! See what's new in the release blog

Qtimer::singleshot slot completed

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 3.8k Views 2 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    Hi All
    Is there any way I can find out that slot
    QTimer::singleShot(1500, this, std::bind(&MyClass::crossCapture, this, getMousePointerX(), getMousePointerY()));

    has been completed

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      put qDebug("Completed"); as the first line of MyClass::crossCapture

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        I am passing a reference variable as bool in slot of Qtimer::singleShot and then accesing this variable in called and putting a while loop on the same to check of the slot is completed any other way to do that

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          Are you using multiple threads? if not what you are doing is totally useless. No instruction can be performed while another is in the same thread

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          2
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #5

            @VRonin said in Qtimer::singleshot slot completed:

            hat you are doing is totally usel

            I am using multple thread one is thread1 amd other is main Gui threadd

            Qt Enthusiast about 6 hours ago
            Hi All

            Is there any way I can find out that slot updateGui is completed .

            QTimer::singleShot(0, this, updateinMaingui());

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              Then the only solution is have a signal in the main thread that fires when that method completed

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              1
              • Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #7

                if you can help me with the sample code

                1 Reply Last reply
                0
                • VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by SGaist
                  #8
                  class MyClass : public QObject{
                  Q_OBJECT
                  
                  // other stuff
                  
                  public:
                  Q_SIGNAL void crossCaptureFinished();
                  void crossCapture(int x, int y){
                  
                  //other stuff
                  
                  emit crossCaptureFinished();
                  }
                  };
                  

                  [edit: added missing emit keyword SGaist]

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  1 Reply Last reply
                  2
                  • Pablo J. RoginaP Offline
                    Pablo J. RoginaP Offline
                    Pablo J. Rogina
                    wrote on last edited by
                    #9

                    @Qt-Enthusiast could you please described in words what's your requirement or what you're trying to do overall? You've already have asked about QTimer::singleShot, and now this loop inside it, it sounds that you might be over complicating things...

                    Upvote the answer(s) that helped you solve the issue
                    Use "Topic Tools" button to mark your post as Solved
                    Add screenshots via postimage.org
                    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    4

                    • Login

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