2017-10-24 10 views
0

を使用して.PROファイルを作成することができます私は.cpp.hファイルを使用してプロジェクトファイル.proを作ることができ、これGitHub demoファイルはCMakeLists.txt,MainWindow.cpp MainWindow.h,MainWindow.uimain.cppファイルが含まれているが、私は.proは、私が.cppファイルと.hファイル

+2

あなたはおそらくプロのファイルを必要としないので、CMakeLists.txtがあります。 – drescherjm

+0

@drescherjm QTを通じてプロジェクトを開く方法 – Rooter

+1

QtCreatorがCMakeLists.txtを使用すると思います。私は、.proファイルを全く使わずにQtの開発をしています。しかし、私はqtcreatorをあまり使用していないと言っていますが、私は主にVisual Studioプロジェクトを生成するためにCMakeを使用しています。 – drescherjm

答えて

1

作ることができるか何.proファイルはありませんこのコードを実行するための最初のステップは、ターミナルを開き、実行のために.PROを生成することである。

qmake -project 

.PROファイルを含むフォルダの名前で生成されと同様のコンテンツを含むことになります:

sizegripitem-master.pro私たちは、私はクラスを参照してくださいとだけ私たちは以下を追加し、このためのモジュールコア、GUIウィジェットを必要とし、モジュールを示すために持っているこれらの後

###################################################################### 
# 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 

QT  += core gui 

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 

あなたがやるべきもう一つは、ファイルmain.cppに変化しで、Qt5と互換​​性があるように、コードの行を更新している:

#include <QtGui/QApplication> 

へ:

#include <QApplication> 
+0

このコードを実行する必要があります 'qmake -project' – Rooter

+0

端末、 Windowsの場合は、コードの同じフォルダにcmdを置いてください。 – eyllanesc

+0

@RooterあなたがWindowsにいる場合、cmdを開く簡単な方法は、Ctrl + Shitfを押して右クリックすることです。オプションの1つでは、cmdが開きます。 – eyllanesc

関連する問題