好吧...所以我对 Qt 很陌生。我刚刚将它安装在我的 Ubuntu 发行版上。我创建了一个新的测试应用程序,以查看它是否适用于我的 ../helloworld/ 目录中的以下文件 (helloworld.cpp):
/* helloworld.cpp */
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(250, 150);
window.setWindowTitle("Simple example");
window.show();
return app.exec();
}
我跑来qmake -project
生成 helloworld.pro 文件。接下来我运行qmake
以生成 Makefile 接下来我运行make
以编译并得到以下输出/错误:
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG
-DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++-64 -I.
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4
-I. -I. -o helloworld.o helloworld.cpp
helloworld.cpp:1:24: fatal error: QApplication: No such file or directory
compilation terminated.
make: *** [helloworld.o] Error 1
意味着 helloworld.o 文件丢失了......我该如何解决这个问题?我尝试QT += webkit
像另一个讨论所说的那样添加......但这也不起作用。
那里的任何代码猴子都知道如何解决这个问题???我将不胜感激!