我可以使用.cpp和.h文件制作.pro文件吗?
Can I make .pro file using .cpp and .h files
可以使用.cpp
和.h
文件制作项目文件.pro
,这个GitHub演示文件包含CMakeLists.txt,MainWindow.cpp MainWindow.h,MainWindow.uimain.cpp
文件,但是没有.pro
文件如何制作.pro
为了执行此代码,第一步是生成 .pro,因为它打开一个终端并执行:
qmake -project
将生成一个 .pro 文件,其中包含包含该文件的文件夹的名称,并将包含类似于以下内容的内容:
sizegripitem-master.pro
######################################################################
# Automatically generated by qmake (3.1) Tue Oct 24 12:36:31 2017
######################################################################
TEMPLATE = app
TARGET = sizegripitem-master
INCLUDEPATH += .
# The following define makes your compiler warn you if you use any
# feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input
HEADERS += SizeGripItem.h demo/MainWindow.h
FORMS += demo/MainWindow.ui
SOURCES += SizeGripItem.cpp demo/main.cpp demo/MainWindow.cpp
在这些之后,我们必须指出模块,正如我所看到的,类只需要模块核心、gui 和小部件,为此我们添加以下内容:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
您应该做的另一件事是更新一行代码以与Qt5兼容,在文件main中.cpp更改:
#include <QtGui/QApplication>
自:
#include <QApplication>
相关文章:
- 如何将网络模块添加到 QT pro 文件中?
- 如何在.pro文件中为TARGET使用空格和尖括号
- 如何在Qt pro文件中添加导出路径
- 将文件复制到 pro/pri 文件中的新目录
- 需要更新Qt .pro和Visual Studio .vcxproj添加新文件
- 如何在QT中使用pro文件在重新编译时执行shell命令?
- Qt .pro 文件获取 Qtkit 名称
- 从.pro编译可执行文件
- 我的C文件是从Pro*C生成的吗
- 我可以使用.cpp和.h文件制作.pro文件吗?
- QT Pro文件条件液体
- 如何在project.pro呼叫中从带源代码的嵌套文件夹中制作文件
- 将共享库添加到Qt .pro文件中
- 如何让Visual Assist解析Pro*C(*.pc)文件
- 将SOCI与qt =如何编写好 *.pro文件
- 是否可以在 qmake .pro 文件中设置视觉工作室项目属性
- QT-在pro中指定DLL路径.文件
- qmake 不会将库从 .pro 文件添加到生成文件
- 当您添加 qmake 文件(.pro) 时,这些命令的含义是什么?
- 我的旧Qt项目文件(.pro文件),它正在工作;不创建任何文件(moc_ 或 .obj 文件)。为什么它退出构建步骤什么都不做?