我正在尝试学习 Qt 5.3,这是我的第一个程序(hello world)。当我尝试构建时,它显示此错误:
extra characters after test expression.
我完全不明白为什么会出现这个错误。我只是从网上拿了一些简单的代码来检查我是否正确安装了Qt。 代码如下:
#include <QApplication>
#include <QPushButton>
int main(int argc, char **argv)
{
QApplication app (argc, argv);
QPushButton button ("Hello world !");
button.show();
return app.exec();
}
错误显示在第 3、5、6、8 行。 我对Qt完全陌生,所以请给一个简单的解释。
最佳答案
检查 .pro 文件。有时是因为你没有在最后一行的末尾没有黑斜线:
HEADERS += Qt/mainwindow.h \
Qt/MPrintableWidget.h \
Qt/MPrintableWidgetGroup.h # Oooops forgot the \ here
Qt/MFixedSizeDialog.h \
Qt/MScreenPage.h
这里的每一行除了最下面的一行都需要以反斜杠结尾。
关于c++ - Qt 5 构建错误 : extra characters after test expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24981050/