Results 1 to 20 of 33

Thread: QObject::killTimers() warning after timer stopped from its own thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QObject::killTimers() warning after timer stopped from its own thread

    This works fine for me on Qt 4.8 and 5.0 RC2. I'm not getting any warnings.

    Qt Code:
    1. include <QtCore>
    2.  
    3. class Worker : public QObject {
    4. Q_OBJECT
    5. public:
    6. Worker() : QObject(){
    7. timer = new QTimer(this);
    8. timer->setInterval(1000);
    9. }
    10. public slots:
    11. void start() { qDebug() << Q_FUNC_INFO; timer->start(); }
    12. void stop() { qDebug() << Q_FUNC_INFO; timer->stop(); }
    13. private:
    14. QTimer *timer;
    15. };
    16.  
    17. #include "main.moc"
    18.  
    19. int main(int argc, char **argv) {
    20. QCoreApplication app(argc, argv);
    21. QThread thread;
    22. Worker *worker = new Worker;
    23. worker->moveToThread(&thread);
    24. thread.start();
    25. QMetaObject::invokeMethod(worker, "start");
    26. QMetaObject::invokeMethod(worker, "stop");
    27. QObject::connect(&app, SIGNAL(aboutToQuit()), &thread, SLOT(quit()));
    28. QTimer t;
    29. t.start(1000);
    30. QObject::connect(&t, SIGNAL(timeout()), &app, SLOT(quit()));
    31. app.exec();
    32. thread.wait();
    33. }
    To copy to clipboard, switch view to plain text mode 

    You can build on this example to check your actual code (with timers and stuff).

    Edit: I even added the timer stuff to the code, still works as expected.
    Last edited by wysota; 18th December 2012 at 02:03.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 29th July 2010, 05:41
  2. QObject::killTimer Warning Messages
    By mclark in forum Qt Programming
    Replies: 7
    Last Post: 11th September 2008, 20:10
  3. how to enable a timer in a non-gui thread?
    By zeopha in forum Qt Programming
    Replies: 3
    Last Post: 5th August 2008, 09:29
  4. Replies: 2
    Last Post: 24th March 2008, 16:59
  5. QObject::moveToThread warning
    By mnemonic_fx in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2007, 22:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.