i try to invoke Slot in thread object when threas started but getting this error:
Object::connect: No such slot Worker::doWork(pFoo)
the thread executing code:
// main class
m_WorkerThread = new QThread();
FooStack* pfooStack = InternalStorageManager::getInstance()->getStack();
m_Worker = new Worker();
bool done = connect(m_WorkerThread,
SIGNAL(started()),
m_Worker,
SLOT(doWork(pfooStack)));
m_Worker->moveToThread(m_WorkerThread);
m_WorkerThread->start();
// class Worker
// cpp imple
void Worker::doWork(FooStack *& rp_urlsStack)
{
}
// header
class Worker : public QObject
{
Q_OBJECT
public :
Worker();
~Worker();
public slots:
void doWork(FooStack *&);
};
Object::connect: No such slot Worker::doWork(pFoo)
You can't pass objects in connection declarations.
Can't you pass pfooStack
into the Worker
constructor?
EDIT:
class Main : ...
{
...
void startThread(); // The method in your example.
private slots:
void startWork();
...
};
void Main::startThread()
{
m_WorkerThread = new QThread();
m_Worker = new Worker();
bool done = connect(m_WorkerThread, SIGNAL(started()),
this, SLOT(startWork()));
m_Worker->moveToThread(m_WorkerThread);
m_WorkerThread->start();
}
void Main::startWork()
{
m_Worker->doWork(InternalStorageManager::getInstance()->getStack());
}