I get compile error that explain
undefined reference to `vtable for Test'
If i remove/comment Q_OBJECT macro, compiler is fine. I think theres problem with class Test.
like compiler don't know what to do with Q_OBJECT macro.
my environtment is mingw64 with qmake tool.
what i need to do to make compiler knows what Q_OBJECT macro is?
#include <QApplication>
#include <QWidget>
#include <QObject>
#include <QPushButton>
#include <QGridLayout>
#include <QMessageBox>
class Test: public QObject {
Q_OBJECT
public slots:
void message() {
QMessageBox message;
message.setText("Click event was triggered.");
message.exec();
};
};
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
Test test;
QWidget *window = new QWidget;
QGridLayout *layout = new QGridLayout(window);
QPushButton *login = new QPushButton("Info");
QObject::connect(login, SIGNAL(clicked()), &test, SLOT(message()));
layout->addWidget(login, 0, 0);
window->setLayout(layout);
window->show();
return app.exec();
}