I just took a look at Threading Basics – Example 4: A Permanent Thread [qt-project.org] .
I have a singleton in my application, derived from QObject. And I would like to make it do all it’s work in a different thread. The linked example seems to be a good starting point, but based on what I know about QThreads, I wouldn’t know how the Thread-class mentioned in the example could work.
The goal is to have an object live in a thread, or, (maybe?) even better, have it run all it’s functions in a different thread and reside in the main thread when doing nothing.
Going back to the example, what would
thread.launchWorker(worker);
do to make this thing work? The QMetaObject::invokeMethod() part looks like it might be what I need.
I am not yet sure how to tackle this problem in the most elegant way, so I would welcome any ideas for a better solution. :)
↧
[solved] Question regarding threading example: How to make an object "live" in a thread permanently?
↧