You can put the timer child of the object, so moveToThread() should move the children too: https://doc.qt.io/Qt-5/qobject.html#moveToThread
-----Original Message----- From: Interest <interest-boun...@qt-project.org> On Behalf Of Tom Isaacson Sent: April 24, 2019 5:11 PM To: Interest@qt-project.org Subject: [Interest] Set a timer for a different thread I've got some legacy code where a timer is firing on the wrong thread. The sequence is: 1. Thread instantiates MyClass. 2. MyClass constructor calls QTimer::singleShot(60 * 1000, this, &MyClass::OnTimer); 3. Move class to thread by calling MyClass.moveToThread(); 4. OnTimer is called on the wrong thread. I assume because the constructor sets the timer before the class is moved to the thread, the timer is firing on the wrong thread. Obviously I can move the timer to a different function then call that after moveToThread() but is there a standard way of fixing this? Tom Isaacson _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest