Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Cannot stop QTimer from another thread



  • I hope this is an easy one. I received an error during shutdown of my app that was roughly "Cannot stop a QTimer from another thread."

    I'm not doing anything to deliberately call the Timer->stop() or the Timer->~QTimer() methods from a different thread. Suggestions on how to troubleshoot?



  • do you have any timer->stop() in your code?
    In which thread QTimer object created? what is the current thread affinity of QTimer object?


  • Moderators

    @John-Howe said in Cannot stop QTimer from another thread:

    Suggestions on how to troubleshoot?

    Set QT_FATAL_WARNINGS as an environment variable with a value of 1. Run your program in the debuger, when it crashes (which it will at the point of the "Cannot stop a QTimer from another thread." warning) extract a stack trace. Post it here.
    That warning usually means that something's not right with your objects' thread affinity.



  • use user define signal instead of direct stop to Qtimer from another thread.


Log in to reply