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. Looking to call a function withour user intervention
QtWS25 Last Chance

Looking to call a function withour user intervention

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 5 Posters 2.0k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #8

    Use a QTimer::singleShot with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    bart.hollisB 1 Reply Last reply
    2
    • SGaistS SGaist

      Use a QTimer::singleShot with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop.

      bart.hollisB Offline
      bart.hollisB Offline
      bart.hollis
      wrote on last edited by
      #9

      @SGaist said in Looking to call a function withour user intervention:

      Use a QTimer::singleShot with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop.

      Could you please give me more detail as how to implement this?

      JonBJ 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #10

        Same as usual except that you use 0 as timeout value and you call that as the last thing in your constructor.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        bart.hollisB 1 Reply Last reply
        2
        • bart.hollisB bart.hollis

          @SGaist said in Looking to call a function withour user intervention:

          Use a QTimer::singleShot with a value of 0 for the delay, then you'll have your GUI running and the method called right after the first round of the event loop.

          Could you please give me more detail as how to implement this?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #11

          @bart.hollis
          I suggested you look at https://stackoverflow.com/a/38749911/489865 or which does actually give code for using QTimer::singleShot.

          1 Reply Last reply
          0
          • SGaistS SGaist

            Same as usual except that you use 0 as timeout value and you call that as the last thing in your constructor.

            bart.hollisB Offline
            bart.hollisB Offline
            bart.hollis
            wrote on last edited by
            #12

            @SGaist said in Looking to call a function withour user intervention:

            Same as usual except that you use 0 as timeout value and you call that as the last thing in your constructor.

            That would be the MainWindow constructor?

            Then, do I understand correctly that I use the slot mentioned to trigger my function?

            From Docs: QTimer::singleShot(200, this, SLOT(updateCaption()));

            1 Reply Last reply
            0
            • bart.hollisB Offline
              bart.hollisB Offline
              bart.hollis
              wrote on last edited by
              #13

              SGaist
              Your suggestion works just as I want! Now, I just need to understand WHY! :)

              1 Reply Last reply
              0
              • bart.hollisB Offline
                bart.hollisB Offline
                bart.hollis
                wrote on last edited by bart.hollis
                #14

                Now, I need to mark this thread as solved. I know how to do that!
                But I should click something that gives points to reputation. I know I saw that somewhere! (mutter, mutter, mutter) I hate when I don't know what I'm doing!

                Anyway, Thanks SGaist! Very Much!

                aha_1980A 1 Reply Last reply
                0
                • bart.hollisB bart.hollis

                  Now, I need to mark this thread as solved. I know how to do that!
                  But I should click something that gives points to reputation. I know I saw that somewhere! (mutter, mutter, mutter) I hate when I don't know what I'm doing!

                  Anyway, Thanks SGaist! Very Much!

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #15

                  @bart.hollis

                  You can upvote a post with the small up arrow right below each post. The down arrow is for downvoting (and should be used in rare cases). The number in between the both shows the current voting for a post and are therefore a sign for it's quality.

                  Regards

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  0
                  • bart.hollisB Offline
                    bart.hollisB Offline
                    bart.hollis
                    wrote on last edited by
                    #16

                    AHA! (Not trying to steal your handle!) Thanks!

                    aha_1980A 1 Reply Last reply
                    0
                    • bart.hollisB bart.hollis

                      AHA! (Not trying to steal your handle!) Thanks!

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #17

                      @bart.hollis You're welcome :)

                      Qt has to stay free or it will die.

                      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