Unsolved How to call functor with QThread
-
I have a class with an operator() overloaded.
class MyWorker : public QObject { Q_OBJECT private: // ... signals: void t_changed(const QString &); public: void operator()(); // ... };
How does one call the functor of MyWorker using QThread?
my_worker = std::make_unique<MyWorker>(this); // ... QThread *my_thread = new QThread; my_worker->moveToThread(my_thread); my_thread->start(); // I want MyWorker::operater()() to be called.
Any help much appreciated.
-
Hi,
If you want to use QThread, you should rather use the working object approach as described in QThread's documentation. Replace that operator with a slot as shown in said documentation.