簡體   English   中英

我可以使用 .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

在這些之后,我們必須指明模塊,因為我看到這些類只需要模塊 core、gui 和 widget 為此我們添加以下內容:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

您應該做的另一件事是更新一行代碼以與 Qt5 兼容,在文件 main.cpp 更改中:

#include <QtGui/QApplication>

到:

#include <QApplication>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM