不赞成包含include/Qt中的头文件
Inclusion of header files from include/Qt is deprecated
我最近开始用Qt4编写C++Gui编程。
然而,我无法通过第一个教程。
#include <QApplication>
#include <QTextEdit>
int main(int argv, char **args)
{
QApplication app(argv, args);
QTextEdit textEdit;
textEdit.show();
return app.exec();
}
每次我试图编译这个,我都会得到:
C:Qt4.8.0andrew>qmake -project
C:Qt4.8.0andrew>qmake
C:Qt4.8.0andrew>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Qt/4.8.0/andrew'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -
DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..includ
eQtCore" -I"..includeQtGui" -I"..include" -I"." -I"..includeActiveQt" -I"d
ebug" -I"..mkspecswin32-g++" -o debugtutone.o tutone.cpp
In file included from tutone.cpp:1:0:
C:Qt4.8.0includeQtQapplication.h:3:10: warning: #warning "Inclusion of head
er files from include/Qt is deprecated." [-Wcpp]
In file included from tutone.cpp:2:0:
C:Qt4.8.0includeQtQpushbutton.h:3:10: warning: #warning "Inclusion of heade
r files from include/Qt is deprecated." [-Wcpp]
tutone.cpp: In function 'int qMain(int, char**)':
tutone.cpp:11:7: error: 'class QApplication' has no member named 'setMainWidget'
mingw32-make[1]: *** [debug/tutone.o] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/4.8.0/andrew'
mingw32-make: *** [debug] Error 2
由于我是Qt的新手,对编译也相当陌生,所以我认为错误就在我这边。我是不是说标题不对?
我的.pro文件如下:
######################################################################
# Automatically generated by qmake (2.01a) Thu Jan 19 12:41:21 2012
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += tutone.h
C:/Qt/4.8.0/include/Qt/Qapplication.h
../include/QtGui/qapplication.h
../src/gui/kernel/qapplication.h
C:/Qt/4.8.0/include/Qt/Qpushbutton.h
../include/QtGui/qpushbutton.h
../src/gui/widgets/qpushbutton.h
SOURCES += tutone.cpp
tutthree.cpp
../src/gui/kernel/qapplication.cpp
../src/gui/widgets/qpushbutton.cpp
感谢
由于Qt构建设置中的一个错误,这是一个错误
这不是问题,并且已经记录在Qt错误跟踪器上
运行qmake -project
后,应在.pro文件中添加QT
变量。然后,您可以删除这些奇怪的HEADERS和SOURCES(并将Qt库动态链接到您的程序):
QT += core gui # <-- this line
TEMPLATE = app
TARGET = ProjectNameHere
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += tutone.h
SOURCES += tutone.cpp
tutthree.cpp
相关文章:
- 如何在cpp文件之间切换窗口?在Qt中
- Qt 5.11.2 (Clang 8.0 (Apple), 64 位), 找不到 QJSEngine 文件
- 使用 Bazel 生成 QT 资源文件
- Qt C++:不同文件中同一命名空间的多个Q_NAMESPACE
- 如何识别项目是 QT 中的文件还是文件夹
- 使用 Cmake 在 Qt Creator 中显示头文件
- 如何将网络模块添加到 QT pro 文件中?
- 如何在 qt for windows 中使用 QAxObject 创建 docx 和 doc 文件?
- 如何将 json 数据附加到 Qt 中的现有 json 文件中
- 如何在 CMakeLists.txt Qt Creator 中包含头文件?
- cmake:构建依赖于非源文件.Qt帮助生成
- 如何从 txt 文件 - Qt 中读取特定行
- QIODevice::read:设备未打开远程JSON文件QT
- 在iOS设备上找不到文件QT创建者C QstandardPaths :: StandardLocations(Qs
- 将长字符流写入文本文件QT C++
- 删除单行文本文件QT
- 在.pro文件QT中定义带有转义字符的字符串宏
- 复制多个文件段到一个文件- Qt
- 编译 moc 文件 Qt 4.5.2 intrin.h 意外类型 "void" Visual Studio 2015
- 文件输入-未读取的文件QT