Ich fange erst neu an mit Qt zu programmieren, ich habe folgenden Code und weiß nicht warum ich ihn nicht kompilieren kann:
Gui.h
Code: Alles auswählen
...
class Gui : public QMainWindow
{
Q_OBJECT
public:
Gui(QMainWindow *parent = 0);
~Gui();
public slots:
void StartProcedure();
void AbortProcedure();
void QuitApplication();
};
...
Code: Alles auswählen
#include "Gui.h"
Gui::Gui(QMainWindow *parent)
: QMainWindow (parent)
{
//Groeße des Widgets, Breite x Hoehe
setFixedSize(600, 340);
setWindowTitle("MPF Station");
//MENUBAR
QMenuBar *mnbMain = new QMenuBar();
mnbMain->setFixedSize(600, 32);
//--FILE Menu
QMenu *fileMenu = new QMenu(tr("Datei"));
//--SETTINGS
QAction *actSettings = new QAction(tr("Einstellungen"), this);
fileMenu->addAction(actSettings);
//--SEPARATOR
fileMenu->addSeparator();
//--CLOSE
QAction *actClose = new QAction(tr("Beenden"), this);
QObject::connect(actClose, SIGNAL(triggered()), this, SLOT(QuitApplication()));
fileMenu->addAction(actClose);
...
}
void Gui::QuitApplication()
{
//Programm wird beendet falls der Benutzer mit JA bestätigt.
QMessageBox msgBox;
msgBox.setText(tr("Wollen Sie das Programm wirklich beenden?"));
QPushButton *yesButton = msgBox.addButton(tr("Ja"), QMessageBox::ActionRole);
msgBox.addButton(tr("Nein"), QMessageBox::ActionRole);
msgBox.exec();
if (msgBox.clickedButton() == yesButton){
qApp->quit();
}
}
In function `ZN3GuiC2EP11QMainWindow':D:/Entwicklung/MPFStation_v2/Gui.cc:28: undefined reference to `vtable for Gui'
:D:/Entwicklung/MPFStation_v2/Gui.cc:28: undefined reference to `vtable for Gui'
build/Debug/GNU-Windows/Gui.o: In function `ZN3GuiC1EP11QMainWindow':D:/Entwicklung/MPFStation_v2/Gui.cc:28: undefined reference to `vtable for Gui'
:D:/Entwicklung/MPFStation_v2/Gui.cc:28: undefined reference to `vtable for Gui'
build/Debug/GNU-Windows/Gui.o: In function `ZN3GuiD2Ev':D:/Entwicklung/MPFStation_v2/Gui.cc:98: undefined reference to `vtable for Gui'
build/Debug/GNU-Windows/Gui.o:D:/Entwicklung/MPFStation_v2/Gui.cc:98: more undefined references to `vtable for Gui' follow
build/Debug/GNU-Windows/Gui.o: In function `ZThn8_N3GuiD0Ev':D:/Entwicklung/MPFStation_v2/Gui.cc:(.text$_ZN3Gui2trEPKcS1_[Gui::tr(char const*, char const*)]+0x1c): undefined reference to `Gui::staticMetaObject'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [dist/Debug/GNU-Windows/mpfstation_v2.exe] Error 1
mingw32-make[1]: Leaving directory `D:/Entwicklung/MPFStation_v2'
mingw32-make: *** [.build-impl] Error 2
Wenn ich Q_OBJECT auskommentiere dann funktioniert alles wunderbar bis auf den einen Slot eben -> eh' klar, ohne Q_OBJECT keine eigenen SLOTS.
Die Ergebnisse aus der Suche waren für mich leider nicht erfolgreich. Weiß jemand Rat?
Vielen Dank im vorraus!
lg Mario