Unresolved external symbol signal
-
I created an instance of
QGuiApplication
and a signal in order test if it works and I always get that the compiler could not resolve external symbols:test.hpp:
#ifndef TEST_HPP #define TEST_HPP #include <QGuiApplication> class test : public QGuiApplication { public: explicit test(int &argc, char **argv); signals: void signalTest(); }; #endif // TEST_HPP
test.cpp:
#include "test.hpp" test::test(int &argc, char **argv) : QGuiApplication(argc, argv) { emit signalTest(); }
I tried to clean the build, remove the built files and build again, and nothing.
-
add Q_OBJECT to your class
class test : public QGuiApplication
{
Q_OBJECTand clean, and rebuild all
All classes that uses signals&slots must have this
-
@Minupi
well the Q_OBJECT is used by the moc.exe compiler and sometimes its
a bit lazy it seems. so when anything else fails, i delete the build folder :)
Well, its need for the meta system used for signals.
But frankly I never tried to make a QApplication subclass but normally that the
case with all other subclassing.
Update: QApplication is a QCoreApplication which inherits from QObject -
@Minupi
note. sometimes running qmake will also work.
It my understanding that "make file" calls moc.exe
But i have had cases where it would first like after I deleted build folder.
(regardless of clean/qmake/rebuild all)