Rooter
Rooter

Reputation: 383

Can I make .pro file using .cpp and .h files

Can I make project file .pro using .cpp and .h files,This GitHub demo file contain CMakeLists.txt,MainWindow.cpp MainWindow.h,MainWindow.uimain.cpp files,but there is no .pro file how can I make .pro

Upvotes: 1

Views: 1372

Answers (1)

eyllanesc
eyllanesc

Reputation: 244282

In order to execute this code the first step is to generate the .pro for it opens a terminal and executes:

qmake -project

A .pro file is generated with the name of the folder containing it and will contain content similar to:

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:

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:

#include <QtGui/QApplication>

to:

#include <QApplication>

Upvotes: 1

Related Questions