Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QThreads problem: QObject::startTimer: Timers cannot be started from another thread
Forum Updated to NodeBB v4.3 + New Features

QThreads problem: QObject::startTimer: Timers cannot be started from another thread

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 1.3k 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I have the following problem: I created a QObject called Controller which runs in its own thread. This "Controller" has a member QObject called "Worker" which contains a QTimer. When I try to start the QTimer inside a function of worker, I get the error message

    QObject::startTimer: Timers cannot be started from another thread
    

    However, when in the cnstructor of Worker I set the parent QObject to "Controller" I don't get this message. I don't understand why this is.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxwell31
      wrote on last edited by maxwell31
      #2

      Ok, the relevant documentation for this is this:

      Note: A QObject's member variables do not automatically become its children. The parent-child relationship must be set by either passing a pointer to the child's constructor, or by calling setParent(). Without this step, the object's member variables will remain in the old thread when moveToThread() is called.

      The problem was that I used moveToThread on "Controller" but the child "Worker" would remain in the old thread if it is not a QObject child.

      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