我可以使用.cpp
和.h
文件制作项目文件.pro
吗,这GitHub demo文件包含 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>
关于c++ - 我可以使用 .cpp 和 .h 文件制作 .pro 文件吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46916327/