Hi guys, I'm facing a problem with Q_OBJECT macro.
I've built a MainWindow with Designer, then I've declared a class which inherits from the class generated with moc from that .ui file and from QMainWindow.
I've declared a private slot in this new class, with Q_OBJECT macro defined but, when I run make, I got the following error:
And if I don't define Q_OBJECT macro I got no errors, but a custom slot is not defined.In file included from moc_GeneratorMainWindow.cpp:10:
GeneratorMainWindow.h:38:7: warning: no newline at end of file
moc_GeneratorMainWindow.cpp:40: error: `staticMetaObject' is not a member of
type `Ui::GeneratorMainWindowUI'
moc_GeneratorMainWindow.cpp: In member function `virtual void*
GeneratorMainWindow::qt_metacast(const char*)':
moc_GeneratorMainWindow.cpp:57: error: 'class Ui::GeneratorMainWindowUI' has no
member named 'qt_metacast'
moc_GeneratorMainWindow.cpp: In member function `virtual int
GeneratorMainWindow::qt_metacall(QMetaObject::Call , int, void**)':
moc_GeneratorMainWindow.cpp:63: error: 'class Ui::GeneratorMainWindowUI' has no
member named 'qt_metacall'
make[1]: *** [moc_GeneratorMainWindow.o] Error 1
make[1]: Leaving directory `/home/leonardo/svn/3WDGFGeneratorFrontEnd/src'
make: *** [sub-src-make_default] Error 2
My code is this:
Qt Code:
//GeneratorMainWindow.h #ifndef GENERATORMAINWINDOW_H #define GENERATORMAINWINDOW_H #include <QMainWindow> #include "GeneratorMainWindowUI.h" { Q_OBJECT public: private slots: void showAddFieldDialog(); }; #endif //GeneratorMainWindow.cpp #include "GeneratorMainWindow.h" #include "AddCustomFieldDialog.h" GeneratorMainWindow::GeneratorMainWindow(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { setupUi(this); mainSplitter->setStretchFactor(1,1); connect( addButton, SIGNAL(clicked()), this, SLOT(showAddFieldDialog()) ); } void GeneratorMainWindow::showAddFieldDialog() { AddCustomFieldDialog *addDialog = new AddCustomFieldDialog(this); addDialog->show(); }To copy to clipboard, switch view to plain text mode
Any ideas?
Thanx a lot in advance.
Bookmarks