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
-
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
@mrjj That is weird, I tried and I got a lot of errors before, maybe because I needed to delete/clean first.
I thought thatQ_OBJECT
was only supposed to be used withQObject
classes.Thank you, it is solved.
-
@mrjj That is weird, I tried and I got a lot of errors before, maybe because I needed to delete/clean first.
I thought thatQ_OBJECT
was only supposed to be used withQObject
classes.Thank you, it is solved.
@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
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@mrjj You are right about being a bit lazy. I need to delete the build folder as well sometimes, specially when creating a new class, for sure I will get errors and I need to delete the folder and build again.
-
@mrjj You are right about being a bit lazy. I need to delete the build folder as well sometimes, specially when creating a new class, for sure I will get errors and I need to delete the folder and build again.
@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)