Bonsoir, voici mon probleme :
Lorsque je compile mon code, le compilateur me donne ces erreurs de link :
[Linker error] undefined reference to `vtable for MyApp'
[Linker error] undefined reference to `vtable for MyApp'
[Linker error] undefined reference to `vtable for MyApp'
[Linker error] undefined reference to `vtable for MyApp'
ld returned 1 exit status
[Build Error] [Qtpremprog.exe] Error 1
Je ne vois pas où est l'erreur, car j'ai bien configurer mes options de projets comme il faut, dans l'onglet parametres et le Makefile.
Voici mon code, à tout hasard.... :
ui_premprog.h :
MyApp.h :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 #ifndef UI_PREMPROG_H #define UI_PREMPROG_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QLineEdit> #include <QtGui/QPushButton> #include <QtGui/QWidget> class Ui_Form { public: QPushButton *bCalculer; QLineEdit *lineEdit_3; void setupUi(QWidget *Form) { Form->setObjectName(QString::fromUtf8("Form")); bCalculer = new QPushButton(Form); bCalculer->setObjectName(QString::fromUtf8("bCalculer")); bCalculer->setGeometry(QRect(210, 180, 75, 23)); lineEdit_3 = new QLineEdit(Form); lineEdit_3->setObjectName(QString::fromUtf8("lineEdit_3")); lineEdit_3->setGeometry(QRect(30, 20, 241, 141)); retranslateUi(Form); QSize size(307, 224); size = size.expandedTo(Form->minimumSizeHint()); Form->resize(size); QMetaObject::connectSlotsByName(Form); } // setupUi void retranslateUi(QWidget *Form) { Form->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8)); bCalculer->setText(QApplication::translate("Form", "PushButton", 0, QApplication::UnicodeUTF8)); Q_UNUSED(Form); } // retranslateUi }; namespace Ui { class Form: public Ui_Form {}; } // namespace Ui #endif
MyApp1.cpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #ifndef QtpremProg #define QtpremProg #include "ui_premprog.h" class MyApp : public QWidget, private Ui::Form { Q_OBJECT public: MyApp(QWidget *parent = 0); public slots : void Ecrire(); }; #endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #include <QtGui> #include "MyApp.h" MyApp::MyApp(QWidget *parent) { setupUi(this); connect(bCalculer, SIGNAL(clicked()), lineEdit_3, SLOT(Ecrire())); } void MyApp::Ecrire() { QString chaine = "Ma premiere appli QT en GUI!!!!"; lineEdit_3->setText(chaine); }
main.cpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include <QApplication> #include "MyApp.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); MyApp *dialogue = new MyApp; dialogue->show(); return app.exec(); }
je precise que ui_premprog.h a été crée grâce à Qt designer.
Partager