Reputation: 3487
I'm working in Qt 4.7, and I have a portion of code with signals and slots. It's set up just as normal, namely:
#include <QObject>
//Earlier code...
connect(my_thread, SIGNAL(started()), other_thread, SLOT(process()));
connect(my_thread, SIGNAL(finished()), third_thread, SLOT(some_slot()));
//Later code...
However, when I build it gives an error for each statement saying "C3861: 'connect': identifier not found" Does anyone have any ideas why this may be? Thanks!
Upvotes: 10
Views: 8062
Reputation: 7034
If you use connect in code that is not part of a QObject
derived class, precede the connect with the QObject::
, so the code will become:
//Earlier code...
QObject::connect(my_thread, SIGNAL(started()), other_thread, SLOT(process()));
LE: basically you call the static connect method and when you are not in the scope of a QObject (or a QObject derived class) you need to fully specify the connect you want to call, else the compiler doesn't find it (or it might find a wrong connect in the current scope)
Upvotes: 23