Qt - the compiler does not recognize "connect"

I work in Qt 4.7 and I have a piece of code with signals and slots. It is configured as normal as:

#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 create it, it gives an error for every statement saying "C3861:" connect ": identifier not found" Does anyone have any ideas why this might be? Thanks!

+6
source share
1 answer

If you use the connection in code that is not part of the derived QObject class, before connecting to QObject:: , so the code will become:

 //Earlier code... QObject::connect(my_thread, SIGNAL(started()), other_thread, SLOT(process())); 

LE: basically you call the static connection method and when you are not in the QObject (or QObject derived class) area, you need to completely specify the connection you want to call, otherwise the compiler will not find it (or it may find the wrong connection in the current area )

+16
source

Source: https://habr.com/ru/post/953587/


All Articles