[英]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
In order to execute this code the first step is to generate the .pro for it opens a terminal and executes:为了执行此代码,第一步是生成 .pro 文件,因为它会打开一个终端并执行:
qmake -project
A .pro file is generated with the name of the folder containing it and will contain content similar to:一个 .pro 文件以包含它的文件夹的名称生成,并将包含类似于以下内容的内容:
sizegripitem-master.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
After these we have to indicate the modules, as I see the classes only need the modules core, gui and widget for this we add the following:在这些之后,我们必须指明模块,因为我看到这些类只需要模块 core、gui 和 widget 为此我们添加以下内容:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
Another thing you should do is update a line of code to be compatible with Qt5, in the file main.cpp changes:您应该做的另一件事是更新一行代码以与 Qt5 兼容,在文件 main.cpp 更改中:
#include <QtGui/QApplication>
to:到:
#include <QApplication>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.