QT4 Compiler error
-
Hallo, ich habe bin gerade dabei meine erste QT4 Anwendung zu bauen, jedoch scheitert das gleich. Ich verwende Kdevelop und QT4. Ich habe als erstes
Project->New project->C++->QMake project->Basic Qt4 Application gemacht.
Danach habe ich in den Project Settings alles auf Qt4 umgestellt sprich
QMake Binary : /usr/bin/qmake-qt4
und überall Qt4 Style angeklickt.Kdevelop habe ich danach mehrfach neugestartet.
mein Code:
#include <QApplication> #include <QPushButton> int main(int argc, char *argv[]) { QApplication app(argc, argv); QPushButton hello("Hello world!"); hello.resize(100, 30); hello.show(); return app.exec(); }
Compiler:
cd '/home/osadmin/workspace/test9' && make
cd src/ && make -f Makefile
make[1]: Entering directory/home/osadmin/workspace/test9/src' g++ -c -pipe -fpermissive -g -D\_REENTRANT -Wall -W -DQT\_SHARED -DQT\_CORE\_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I. -o main.o main.cpp main.cpp:22:24: error: QApplication: No such file or directory main.cpp:23:23: error: QPushButton: No such file or directory main.cpp: In function ‘int main(int, char**)’: main.cpp:27: error: ‘QApplication’ was not declared in this scope main.cpp:27: error: expected
;' before ‘app’
main.cpp:29: error: ‘QPushButton’ was not declared in this scope
main.cpp:29: error: expected;' before ‘hello’ main.cpp:30: error: ‘hello’ was not declared in this scope main.cpp:34: error: ‘app’ was not declared in this scope main.cpp: At global scope: main.cpp:25: warning: unused parameter ‘argc’ main.cpp:25: warning: unused parameter ‘argv’ make[1]: Leaving directory
/home/osadmin/workspace/test9/src'
make[1]: *** [main.o] Error 1
make: *** [sub-src-make_default] Error 2
*** Exited with status: 2 ***hat jemand eine Ahnung woran das liegt?
PS: ich verwende Debian - Sid
-
Der findet die Header nicht: QApplication und QPushButton
Wahrscheinlich musst du bei den Einstellungen GUI aktivieren.
-
Hi,
Wie kann ich denn Gui aktivieren?
ich habe jetzt den Include anders gemacht, somit findet er die files, aber es hagelt nur errors
Code:
#include <QtGui/QApplication> #include <QtGui/QPushButton> int main(int argc, char *argv[]) { QApplication app(argc, argv); QPushButton hello("Hello world!"); hello.resize(100, 30); hello.show(); return app.exec(); }
Compiler error:
cd '/home/osadmin/work/test4' && make
cd src/ && make -f Makefile
g++ -c -pipe -fpermissive -g -D_REENTRANT -Wall -W -DQT_SHARED -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I. -o main.o main.cpp
g++ -Wl,--as-needed -o ../bin/test4 main.o -L/usr/lib -lQtCore -lpthread
main.o: In functionmain': /home/osadmin/work/test4/src/main.cpp:26: undefined reference to
QApplication::QApplication(int&, char**, int)'
/home/osadmin/work/test4/src/main.cpp:28: undefined reference toQPushButton::QPushButton(QString const&, QWidget*)' / home/osadmin/work/test4/src/main.cpp:33: undefined reference to
QApplication::exec()'
/home/osadmin/work/test4/src/main.cpp:33: undefined reference toQPushButton::~QPushButton()' /home/osadmin/work/test4/src/main.cpp:33: undefined reference to
QPushButton::~QPushButton()'
/home/osadmin/work/test4/src/main.cpp:33: undefined reference toQApplication::~QApplication()' /home/osadmin/work/test4/src/main.cpp:33: undefined reference to
QApplication::~QApplication()'
main.o: In functionQWidget::resize(int, int)': /usr/include/qt4/QtGui/qwidget.h:945: undefined reference to
QWidget::resize(QSize const&)'
collect2: ld returned 1 exit status
make[1]: *** [../bin/test4] Error 1
make: *** [sub-src-make_default] Error 2
*** Exited with status: 2 ***Woran kann das jetzt liegen? Ich meine bei der Installation kann man via apt ja nicht viel falsch machen. Es muss also irgend ein einstellungsproblem sein, jedoch weiß ich nicht was ich übersehen habe...
-
Irgendwo in den Projekteinstellungen oder im QMake Manager ist da ein GUI Knopf.
-
Ponto schrieb:
Irgendwo in den Projekteinstellungen oder im QMake Manager ist da ein GUI Knopf.
im QMake Manager, oberer Teil -> rechtsklick auf src -> subprojekteinstellungen -> besagter gui knopf..
-
Das wars, funktioniert, Danke
so long
jd