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. Poll method for QMainWindow
Forum Updated to NodeBB v4.3 + New Features

Poll method for QMainWindow

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 3.6k 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.
  • A Offline
    A Offline
    avidamic
    wrote on last edited by
    #1

    Is there already a method in QMainWindow that will get called every frame? I want to implement a polling method but I'm having trouble finding something like an "OnIdle" for this class.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on last edited by
      #2

      You can use "QCoreApplication::hasPendingEvents":http://doc.qt.nokia.com/4.7/qcoreapplication.html#hasPendingEvents to check if the application is idle.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dialingo
        wrote on last edited by
        #3

        I am not sure if I understood your requirement correctly but:

        QTimer with setInterval(0) emits a signal as soon as the event queue is empty.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          avidamic
          wrote on last edited by
          #4

          I think the QTimer with 0 interval is what I need to do. Basically I need to have a method in my QMainWindow subclass to get called every frame. thanks.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            [quote author="avidamic" date="1309357224"]I think the QTimer with 0 interval is what I need to do. Basically I need to have a method in my QMainWindow subclass to get called every frame. thanks.[/quote]

            What do you mean by frame? This timer only calls you, when there is nothing else to do.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              avidamic
              wrote on last edited by
              #6

              By every frame, I mean every tick, every time the application loops, etc. I'm a game developer and come from a MFC background so sorry if my terminology doesn't make sense right off the bat.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                MFC also does not talk of frames. The event loop (also in MFC) is just a while loop that waits for messages in a queue. In MFC there is afaik no method that is called each time, the loop is executed (not by default).

                Every tick would be really fast as tick is typically processor dependent... And if you want to have it each loop, that is overwriting QCoreApplication::notify or installing an event Filkter on the application object. But that would only be called, if there is an event to process.

                like in standard windows:

                @
                while(GetMessage(msg))
                {
                TranslateMessage(msg);
                DispatchMessage(msg);
                }
                @

                You would hang in line 3, so if there is no methode --> no call.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  avidamic
                  wrote on last edited by
                  #8

                  Yep, it's tough to come out of game lingo. Sorry for the confusion.

                  QTimer method worked for me though. 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