QT pro file detailed writing + example, qtpro writing example

Source: Internet
Author: User
Tags qt designer

QT pro file detailed writing + example, qtpro writing example

TEMPLATE: this variable is used to define the mode in which your project will be compiled. If this setting is not available, the system will compile it as application by default.

TEMPLATE = app indicates that the project will be compiled into an application)

Lib (Makefile of the generated Library)

Subdirs (generate Makefile with multi-level Directory management ),

Vcapp, vclib, and vcsubdirs (corresponding to VC in Windows)

TARGET: generate the name of the final TARGET

DESTDIR: Specifies the path to generate the target.

DEPENDPATH: Project dependency path

INCLUDEPATH: Specifies the header file path for the project.

 

SOURCES: source file required by the project

HEADERS: header file required by the project

FORMS: the ui file used by the project (which is generated by the QT designer when the ui file is used)

LIBS: load a dynamic library. LIBS + =./mitab/libmitab. so

TRASHLATIONS: load the language translation *. ts file to be used

RESOURCES: load the resource *. qrc file to be used.

CONFIG: indicates the configuration information of the qmake application.

This variable can be used to specify whether to generate the debug mode or the release mode.

It can also be used to enable the compiler warning (warn_on outputs as many warning messages as possible) or

Close (warn_off-the compiler will output as few warning messages as possible ). It can also be used to configure the Qt library to be loaded.

To use qt + multithreading: CONFIG + = qt thread

Eg:

CONFIG + = debug_and_release

CONFIG (debug, debug | release ){

TARGET = hello

DESTDIR =./debug

} Else {

TARGET = hello

DESTDIR =./release

}

UI_DIR: UIC converts the ui to the directory where the header file is stored.

RCC_DIR: RCC converts the qrc file to the directory where the header file is stored.

MOC_DIR: The MOC command converts the header file containing Q_OBJECT to the directory where the standard header file is stored.

OBJECTS_DIR: directory where the generated target file is stored

DEFINES: the list of additional Preprocessing Program definitions required by the application # In the. h file, you can use: # ifdefinexx_xx_xxx

LIBS + =-L folderPath // path of the introduced lib file-L: Import path

Release: LIBS + =-L folderPath // The lib file path introduced by release

Debug: LIBS + =-L folderPath // lib file path introduced by Debug

RC_FILE = xxx. icns // program icon

QT is cross-platform, so we use the same pro file on different platforms. This requires information about the platform.

Windows is win32 and Linux is unix.

Eg:

The format of dynamic library files in Windows and Linux is different. One is the lib file and the other is the so file.

Win32: LIBS + =./mitab/mitab_ I .lib

Unix: LiBS + =./mitab/libmitab. so

Eg:

Win32 {

SOURCES + = hello_win.cpp // win Platform

}

Unix {

SOURCES + = hello_win.cpp // unix/linux platform

}

To assign the value of this variable to the current variable by adding $ before the name of any other variable. For example:

MY_DEFINES = $ DEFINE # assign the value of DEFINE to MY_DEFINES

 

***************/

QT + = core gui network xml SQL

PATH + =$ $ (PATH) # This PATH variable is a global variable in the projects Option of QT creator.

Export depath + = $ PATH/root/Desktop/TOU/API/header/# If you do not add an absolute PATH to a user-defined useful file, in User-Defined cpp, the system will prompt that the corresponding header file cannot be found.

Message ($ INCLUDEPATH)

DEPENDPATH + =$ $ (PATH)

Message ($ DEPENDPATH)

OBJECTS_DIR = tmp

UI_DIR = inc

MOC_DIR = tmp

RCC_DIR = tmp

RC_FILE = ICON. rc

RESOURCES + =

HEADERS + = \

Inc/widget. h \

Inc/register header. h \

API/header/qextserialbase. h \

API/header/posix_qextserialport.h \

API/header/comport. h \

API/header/Encrypt. h \

API/header/mylineedit. h \

API/header/keyboardwidget. h

 

SOURCES + = \

Src/widget. cpp \

Src/main. cpp \

API/source/qextserialbase. cpp \

API/source/posix_qextserialport.cpp \

API/source/mylineedit. cpp \

API/source/keyboardwidget. cpp \

API/source/comport. cpp

 

FORMS + = \

UI/widget. ui \

UI/keyboardwidget. ui

Contains (CONFIG, Release) {# global function contains

Message (Release build !)

# Release Q_WS_EMBEDED if it is downloaded to the Development Board

DEFINES = QT_NODEBUG_SUPPORT Q_WS_EMBEDED

CONFIG + = warn_off

TARGET = TOU_release

DESTDIR = release

} Else {

Message (Debug build !) # Global function message

DEFINES = DQT_DEBUG_SUPPORT

CONFIG + = warn_on

TARGET = TOU_debug

DESTDIR = debug

}

Win32: {# win

SOURCES + = ###

}

Unix :{

Contains (DEFINES, Q_WS_EMBEDED ){

Export depath + =/usr/local/Trolltech/QtEmbedded-4.8.5-arm/include/Qwt/

LIBS + =-L/usr/local/Trolltech/QtEmbedded-4.8.5-arm/include/Qwt/lib-lqwt

} Else {

Export depath + =/opt/qtsdk-2010.05/qt/include/Qwt/

LIBS + =-L/opt/qtsdk-2010.05/qt/include/Qwt/lib-lqwt

}

}

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.