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. Unresolved timer events
Forum Updated to NodeBB v4.3 + New Features

Unresolved timer events

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 942 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.
  • P Offline
    P Offline
    Peregring-lk
    wrote on last edited by
    #1

    A mini sample file main.cpp:

    @ #include <iostream>
    #include <QCoreApplication>

    class MyApp : public QCoreApplication
    {
    private:
        int m_idtimer;
    
    public:
        MyApp(int nargs, char* argc[]) : QCoreApplication(nargs, argc)
        {
            m_idtimer = startTimer(3000); // 3 segs.
        }
    
    protected:
        void timerEvent(QTimerEvent* e)
        {
            char c = '\0';
    
            std::cout << "timerEvent" << std::endl;
            std::cin >> c;
    
            if (c == 'q') {
                killTimer(m_idtimer);
                quit();
            }
        }
    };
    
    int main(int nargs, char* argc[])
    {
        MyApp app(nargs, argc);
    
        return app.exec();
    }@
    

    Extra mini Makefile:

    @ LDFLAGS = -I/usr/include/qt4 -I/usr/include/qt4/QtCore
    LDLIBS = -lQtCore@

    Compiling and execution:

    @ $ make main
    g++ -I/usr/include/qt4/QtCore main.cpp -lQtCore -o main
    $ ./main
    timerEvent
    1
    timerEvent
    2
    timerEvent
    3
    timerEvent
    q
    $@

    Ok and then, my question. I've made this sample with the purpose of testing if timer events are accumulative.

    When I executing the main program, the next occurs:

    the first timerEvent message is shown after 3 seconds, and timerEvent(&#41; waits a character.

    I press 1 inmediatly.

    3 seconds later, the second timerEvent message appear (as expected).

    I wait some seconds (15 or more) and I press 2

    The third message is shown immediatly (one timer event accumulated).

    I press 3 immediatly.

    And 3 seconds later the fourth message appear (no more timer events accumulated).

    I press q and the program ends.

    Question: Why aren there no more timer events accumulated? Does this behaviour depend on the platform?

    PD: My Qt version is 4.8, my SO Ubuntu 13.04, and my kernel (linux) 3.8.0-19-generic. The running graphic system is Gnome 3.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Yes, this behavior is platform dependent.

      http://qt-project.org/wiki/QtTimers

      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