青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

子彈 の VISIONS

NEVER back down ~~

C++博客 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
  112 Posts :: 34 Stories :: 99 Comments :: 0 Trackbacks
qmake Project Files

Project files contain all the information required by qmake to build your application, library, or plugin. The resources used by your project are generally specified using a series of declarations, but support for simple programming constructs allow you to describe different build processes for different platforms and environments.

Project File Elements

The project file format used by qmake can be used to support both simple and fairly complex build systems. Simple project files will use a straightforward declarative style, defining standard variables to indicate the source and header files that are used in the project. Complex projects may use the control flow structures to fine-tune the build process.

The following sections describe the different types of elements used in project files.

Variables

In a project file, variables are used to hold lists of strings. In the simplest projects, these variables inform qmake about the configuration options to use, or supply filenames and paths to use in the build process.

qmake looks for certain variables in each project file, and it uses the contents of these to determine what it should write to a Makefile. For example, the list of values in the HEADERS and SOURCES variables are used to tell qmake about header and source files in the same directory as the project file.

Variables can also be used internally to store temporary lists of values, and existing lists of values can be overwritten or extended with new values.

The following lines show how lists of values are assigned to variables:

 HEADERS = mainwindow.h paintwidget.h 

Note that the first assignment only includes values that are specified on the same line as the SOURCES variable. The second assignment splits the items across lines by using the \\ character.

The list of values in a variable is extended in the following way:

 SOURCES = main.cpp mainwindow.cpp \
           paintwidget.cpp
 CONFIG += qt 

The CONFIG variable is another special variable that qmake uses when generating a Makefile. It is discussed in the section on general configuration later in this chapter. In the above line, qt is added to the list of existing values contained in CONFIG.

The following table lists the variables that qmake recognizes, and describes what they should contain.

Variable

Contents

CONFIG

General project configuration options.

DESTDIR

The directory in which the executable or binary file will be placed.

FORMS

A list of .ui files to be processed by uic.

HEADERS

A list of filenames of header (.h) files used when building the project.

QT

Qt-specific configuration options.

RESOURCES

A list of resource (.rc) files to be included in the final project. See the The Qt Resource System for more information about these files.

SOURCES

A list of source code files to be used when building the project.

TEMPLATE

The template to use for the project. This determines whether the output of the build process will be an application, a library, or a plugin.

The contents of a variable can be read by prepending the variable name with $$. This can be used to assign the contents of one variable to another:

 TEMP_SOURCES = $$SOURCES 

The $$ operator is used extensively with built-in functions that operate on strings and lists of values. These are described in the chapter on qmake Advanced Usage.

Normally, variables are used to contain whitespace-separated lists of values. However, it is sometimes necessary to specify values containing spaces. These must be quoted in the following way:

 DEST = "Program Files" 

The quoted text is treated as a single item in the list of values held by the variable.

Comments

You can add comments to project files. Comments begin with the # character and continue to the end of the same line. For example:

 # Comments usually start at the beginning of a line, but they
 # can also follow other content on the same line. 

To include the # character in variable assignments, it is necessary to use the contents of the built-in LITERAL_HASH variable. See the variable reference for more information.

Built-in Functions and Control Flow

qmake provides a number of built-in functions to allow the contents of variables to be processed. The most commonly used function in simple project files is the include function which takes a filename as an argument. The contents of the given file are included in the project file at the place where the include function is used. The include function is most commonly used to include other project files:

 include(other.pro) 

Support for conditional structures is made available via scopes that behave like if statements in programming languages:

 win32 {
     SOURCES += paintwidget_win.cpp
 } 

The assignments inside the braces are only made if the condition is true. In this case, the special win32 variable must be set; this happens automatically on Windows, but this can also be specified on other platforms by running qmake with the -win32 command line option (see Running qmake for more information). The opening brace must stand on the same line as the condition.

Simple loops are constructed by iterating over lists of values using the built-in for function. The following code adds directories to the SUBDIRS variable, but only if they exist:

 EXTRAS = handlers tests docs
 for(dir, EXTRAS) {
     exists($$dir) {
         SUBDIRS += $$dir
     }
 } 

More complex operations on variables that would usually require loops are provided by built-in functions such as find, unique, and count. These functions, and many others are provided to manipulate strings and paths, support user input, and call external tools. A list of the functions available can be found in the qmake Advanced Usage chapter of this manual.

Project Templates

The TEMPLATE variable is used to define the type of project that will be built. If this is not declared in the project file, qmake assumes that an application should be built, and will generate an appropriate Makefile (or equivalent file) for the purpose.

The types of project available are listed in the following table with information about the files that qmake will generate for each of them:

Template

Description of qmake output

app (default)

Creates a Makefile to build an application.

lib

Creates a Makefile to build a library.

subdirs

Creates a Makefile containing rules for the subdirectories specified using the SUBDIRS variable. Each subdirectory must contain its own project file.

vcapp

Creates a Visual Studio Project file to build an application.

vclib

Creates a Visual Studio Project file to build a library.

See the qmake Tutorial for advice on writing project files for projects that use the app and lib templates.

When the subdirs template is used, qmake generates a Makefile to examine each specified subdirectory, process any project file it finds there, and run the platform's make tool on the newly-created Makefile. The SUBDIRS variable is used to contain a list of all the subdirectories to be processed.

General Configuration

The CONFIG variable specifies the options and features that the compiler should use and the libraries that should be linked against. Anything can be added to the CONFIG variable, but the options covered below are recognized by qmake internally.

The following options control the compiler flags that are used to build the project:

Option

Description

release

The project is to be built in release mode. This is ignored if debug is also specified.

debug

The project is to be built in debug mode.

debug_and_release

The project is built in both debug and release modes.

build_all

If debug_and_release is specified, the project is built in both debug and release modes by default.

ordered

When using the subdirs template, this option specifies that the directories listed should be processed in the order in which they are given.

warn_on

The compiler should output as many warnings as possible. This is ignored if warn_off is specified.

warn_off

The compiler should output as few warnings as possible.

The debug_and_release option is special in that it enables both debug and release versions of a project to be built. In such a case, the Makefile that qmake generates includes a rule that builds both versions, and this can be invoked in the following way:

 make all 

Adding the build_all option to the CONFIG variable makes this rule the default when building the project, and installation targets will be created for both debug and release builds.

Note that each of the options specified in the CONFIG variable can also be used as a scope condition. You can test for the presence of certain configuration options by using the built-in CONFIG() function. For example, the following lines show the function as the condition in a scope to test whether only the opengl option is in use:

 CONFIG(opengl) {
     message(Building with OpenGL support.)
 } else {
     message(OpenGL support is not available.)
 } 

This enables different configurations to be defined for release and debug builds, and is described in more detail in the Scopes section of the Advanced Usage chapter of this manual.

The following options define the type of project to be built. Note that some of these options only take effect when used on the relevant platform. On other platforms, they have no effect.

Option

Description

qt

The project is a Qt application and should link against the Qt library. You can use the QT variable to control any additional Qt modules that are required by your application.

thread

The project is a multi-threaded application.

x11

The project is an X11 application or library.

When using application or library project templates, more specialized configuration options can be used to fine tune the build process. These are explained in details in the Common Projects chapter of this manual.

For example, if your application uses the Qt library and you want to build it as a multi-threaded application in debug mode, your project file will contain the following line:

 CONFIG += qt thread debug 

Note, that you must use "+=", not "=", or qmake will not be able to use Qt's configuration to determine the settings needed for your project.

Declaring Qt Libraries

If the CONFIG variable contains the qt value, qmake's support for Qt applications is enabled. This makes it possible to fine-tune which of the Qt modules are used by your application. This is achieved with the QT variable which can be used to declare the required extension modules. For example, we can enable the XML and network modules in the following way:

 CONFIG += qt
 QT += network xml 

Note that QT includes the core and gui modules by default, so the above declaration adds the network and XML modules to this default list. The following assignment omits the default modules, and will lead to errors when the application's source code is being compiled:

 QT = network xml # This will omit the core and gui modules. 

If you want to build a project without the gui module, you need to exclude it with the "-=" operator. By default, QT contains both core and gui, so the following line will result in a minimal Qt project being built:

 QT -= gui # Only the core module is used. 

The table below shows the options that can be used with the QT variable and the features that are associated with each of them:

Option

Features

core (included by default)

QtCore module

gui (included by default)

QtGui module

network

QtNetwork module

opengl

QtOpenGL module

sql

QtSql module

svg

QtSvg module

xml

QtXml module

qt3support

Qt3Support module

Note that adding the opengl option to the QT variable automatically causes the equivalent option to be added to the CONFIG variable. Therefore, for Qt applications, it is not necessary to add the opengl option to both CONFIG and QT.

Configuration Features

qmake can be set up with extra configuration features that are specified in feature (.prf) files. These extra features often provide support for custom tools that are used during the build process. To add a feature to the build process, append the feature name (the stem of the feature filename) to the CONFIG variable.

For example, qmake can configure the build process to take advantage of external libraries that are supported by pkg-config, such as the D-Bus and ogg libraries, with the following lines:

 CONFIG += link_pkgconfig
 PKGCONFIG += ogg dbus-1 

More information about features can be found in the Adding New Configuration Features section of the qmake Advanced Usage chapter.

Declaring Other Libraries

If you are using other libraries in your project in addition to those supplied with Qt, you need to specify them in your project file.

The paths that qmake searches for libraries and the specific libraries to link against can be added to the list of values in the LIBS variable. The paths to the libraries themselves can be given, or the familiar Unix-style notation for specifying libraries and paths can be used if preferred.

For example, the following lines show how a library can be specified:

 LIBS += -L/usr/local/lib -lmath 

The paths containing header files can also be specified in a similar way using the INCLUDEPATH variable.

For example, it is possible to add several paths to be searched for header files:

 INCLUDEPATH = c:/msdev/include d:/stl/include 

[Previous: Using qmake] [Contents] [Next: Running qmake]


Copyright © 2008 Trolltech

Trademarks

Qt 4.3.4

posted on 2008-08-04 12:00 子彈のVISIONS 閱讀(1664) 評(píng)論(2)  編輯 收藏 引用 所屬分類: 2.0 工作參考

Feedback

# re: qmake Project Files (.pro) 2008-08-04 12:08 子彈
 
QT中.pro文件的寫法
2008-04-01 15:03
在QT中,有一個(gè)工具qmake可以生成一個(gè)makefile文件,它是由.pro文件生成而來(lái)的,.pro文件的寫法如下:

1. 注釋
從“#”開(kāi)始,到這一行結(jié)束。

2. 指定源文件
SOURCES = *.cpp

對(duì)于多源文件,可用空格分開(kāi),如:SOURCES = 1.cpp 2.cpp 3.cpp
或者每一個(gè)文件可以被列在一個(gè)分開(kāi)的行里面,通過(guò)反斜線另起一行,就像這樣:

SOURCES = hello.cpp \
      main.cpp
一個(gè)更冗長(zhǎng)的方法是單獨(dú)地列出每一個(gè)文件,就像這樣:

    SOURCES += hello.cpp
    SOURCES += main.cpp

這種方法中使用“+=”比“=”更安全,因?yàn)樗皇窍蛞延械牧斜碇刑砑有碌奈募?,而不是替換整個(gè)列表。

3. 指定頭文件
HEADERS = hello.h或者HEADERS += hello.h

列出源文件的任何一個(gè)方法對(duì)頭文件也都適用。

4. 配置信息
CONFIG用來(lái)告訴qmake關(guān)于應(yīng)用程序的配置信息。

    CONFIG += qt warn_on release

在這里使用“+=”,是因?yàn)槲覀兲砑游覀兊呐渲眠x項(xiàng)到任何一個(gè)已經(jīng)存在中。這樣做比使用“=”那樣替換已經(jīng)指定的所有選項(xiàng)是更安全的。
A> qt部分告訴qmake這個(gè)應(yīng)用程序是使用Qt來(lái)連編的。這也就是說(shuō)qmake在連接和為編譯添加所需的包含路徑的時(shí)候會(huì)考慮到Qt庫(kù)的。
B> warn_on部分告訴qmake要把編譯器設(shè)置為輸出警告信息的。
C> release部分告訴qmake應(yīng)用程序必須被連編為一個(gè)發(fā)布的應(yīng)用程序。在開(kāi)發(fā)過(guò)程中,程序員也可以使用debug來(lái)替換release

5. 指定目標(biāo)文件名
TARGET = filename

如果不設(shè)置該項(xiàng)目,目標(biāo)名會(huì)被自動(dòng)設(shè)置為跟項(xiàng)目文件一樣的名稱

6. 添加界面文件(ui)
INTERFACES = filename.ui

7. 平臺(tái)相關(guān)性處理
我們?cè)谶@里需要做的是根據(jù)qmake所運(yùn)行的平臺(tái)來(lái)使用相應(yīng)的作用域來(lái)進(jìn)行處理。為Windows平臺(tái)添加的依賴平臺(tái)的文件的簡(jiǎn)單的作用域看起來(lái)就像這樣:

win32 {
SOURCES += hello_win.cpp
}

所以如果qmake運(yùn)行在Windows上的時(shí)候,它就會(huì)把hello_win.cpp添加到源文件列表中。如果qmake運(yùn)行在其它平臺(tái)上的時(shí)候,它會(huì)很簡(jiǎn)單地把這部分忽略。

8. 如果一個(gè)文件不存在,停止qmake
如 果某一個(gè)文件不存在的時(shí)候,你也許不想生成一個(gè)Makefile。我們可以通過(guò)使用exists()函數(shù)來(lái)檢查一個(gè)文件是否存在。我們可以通過(guò)使用 error()函數(shù)把正在運(yùn)行的qmake停下來(lái)。這和作用域的工作方式一樣。只要很簡(jiǎn)單地用這個(gè)函數(shù)來(lái)替換作用域條件。對(duì)main.cpp文件的檢查就 像這樣:

!exists( main.cpp ) {
   error( "No main.cpp file found" )
}

“!”用來(lái)否定這個(gè)測(cè)試,比如,如果文件存在,exists( main.cpp )是真,如果文件不存在,!exists( main.cpp )是真。

9. 檢查多于一個(gè)的條件
假 設(shè)你使用Windows并且當(dāng)你在命令行運(yùn)行你的應(yīng)用程序的時(shí)候你想能夠看到qDebug()語(yǔ)句。除非你在連編你的程序的時(shí)候使用console設(shè)置, 你不會(huì)看到輸出。我們可以很容易地把console添加到CONFIG行中,這樣在Windows下,Makefile就會(huì)有這個(gè)設(shè)置。但是如果告訴你我 們只是想在當(dāng)我們的應(yīng)用程序運(yùn)行在Windows下并且當(dāng)debug已經(jīng)在CONFIG行中的時(shí)候,添加console。這需要兩個(gè)嵌套的作用域;只要生 成一個(gè)作用域,然后在它里面再生成另一個(gè)。把設(shè)置放在最里面的作用域里,就像這樣:

win32 {
   debug {
     CONFIG += console
   }
}

嵌套的作用域可以使用冒號(hào)連接起來(lái),像這樣:

win32:debug {
CONFIG += console
}

10. 摸板
模板變量告訴qmake為這個(gè)應(yīng)用程序生成哪種makefile。下面是可供使用的選擇:

A> app - 建立一個(gè)應(yīng)用程序的makefile。這是默認(rèn)值,所以如果模板沒(méi)有被指定,這個(gè)將被使用。
B> lib - 建立一個(gè)庫(kù)的makefile。
C> vcapp - 建立一個(gè)應(yīng)用程序的Visual Studio項(xiàng)目文件。
D> vclib - 建立一個(gè)庫(kù)的Visual Studio項(xiàng)目文件。
E> subdirs - 這是一個(gè)特殊的模板,它可以創(chuàng)建一個(gè)能夠進(jìn)入特定目錄并且為一個(gè)項(xiàng)目文件生成makefile并且為它調(diào)用make的makefile。

11. 生成Makefile
當(dāng)你已經(jīng)創(chuàng)建好你的項(xiàng)目文件,生成Makefile就很容易了,你所要做的就是先到你所生成的項(xiàng)目文件那里然后輸入:

Makefile可以像這樣由“.pro”文件生成:

    qmake -o Makefile hello.pro

對(duì)于Visual Studio的用戶,qmake也可以生成“.dsp”文件,例如:

    qmake -t vcapp -o hello.dsp hello.pro
  回復(fù)  更多評(píng)論
  

# re: qmake Project Files (.pro) 2010-08-05 14:14 cosplay
I love your blog so much, and there are just some differences with others'. Hope there will be more wonderful things in your blog. .Happy every day!DXFD  回復(fù)  更多評(píng)論
  

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产视频不卡| 1769国产精品| 亚洲欧美综合| 亚洲欧洲av一区二区三区久久| 国产精品亚洲一区| 久久只精品国产| 欧美高清在线播放| 亚洲欧美日韩一区二区三区在线观看 | 99综合在线| 国产欧美日韩视频一区二区| 久久久蜜桃精品| 欧美福利视频在线观看| 亚洲午夜三级在线| 久久不射中文字幕| 日韩视频专区| 午夜精品一区二区三区在线| 亚洲电影有码| 亚洲一区精品视频| 亚洲国产精品999| 亚洲视频图片小说| 在线免费观看成人网| 日韩午夜免费| 一区精品在线| 亚洲一区免费| 亚洲精品四区| 欧美在线视频一区| 亚洲精品美女91| 久久婷婷综合激情| 亚洲肉体裸体xxxx137| 国产精品大片wwwwww| 久久久久.com| 欧美日韩在线播放一区| 免费日韩av电影| 国产精品视频99| 日韩亚洲在线| 亚洲精品麻豆| 久久视频这里只有精品| 欧美一区二区在线| 欧美日韩高清不卡| 欧美激情视频一区二区三区不卡| 国产免费成人在线视频| 亚洲美女av黄| 日韩视频免费观看| 美女图片一区二区| 另类成人小视频在线| 国产啪精品视频| 亚洲欧美成人网| 亚洲欧美精品在线观看| 欧美日韩在线播放三区| 亚洲欧洲一区| 亚洲黄色视屏| 麻豆成人在线播放| 蜜桃视频一区| 亚洲人成网站999久久久综合| 国产一区二区高清| 欧美在线播放视频| 久久精品国产清自在天天线| 国产农村妇女精品一区二区| 夜夜嗨av一区二区三区网页| 99视频超级精品| 欧美日本在线一区| 亚洲九九爱视频| 亚洲调教视频在线观看| 欧美日韩在线播| 中文欧美字幕免费| 午夜精品久久久久影视| 国产精品自拍视频| 午夜视频在线观看一区二区三区| 欧美一区国产在线| 国产日韩一级二级三级| 久久精品91久久久久久再现| 老司机久久99久久精品播放免费 | 一本久久a久久精品亚洲| 国产精品99久久久久久宅男| 欧美视频在线不卡| 亚洲在线视频网站| 久久久99免费视频| 亚洲欧洲一二三| 欧美日韩久久不卡| 一区二区三区色| 欧美中文日韩| 在线精品一区| 欧美日本一区| 亚洲欧美自拍偷拍| 欧美电影在线播放| 亚洲一区bb| 国产曰批免费观看久久久| 久久综合九九| 99热这里只有成人精品国产| 久久精品国产清高在天天线| 91久久精品国产91久久| 欧美网站在线| 久久人人97超碰国产公开结果| 亚洲高清在线精品| 亚洲欧美在线视频观看| 在线观看中文字幕亚洲| 欧美午夜性色大片在线观看| 久久成人精品无人区| 亚洲人成人一区二区三区| 欧美一区二区三区啪啪 | 欧美日韩亚洲一区三区| 欧美自拍偷拍| 99精品欧美一区二区三区综合在线| 午夜亚洲性色福利视频| 最新国产精品拍自在线播放| 国产精品成人观看视频免费| 久久久国产成人精品| 一本久道久久久| 欧美成人激情视频| 午夜精品福利一区二区三区av| 在线观看久久av| 国产精品日韩久久久久| 欧美激情综合色| 久久精品国产2020观看福利| 在线一区日本视频| 最新亚洲电影| 欧美3dxxxxhd| 久久久www成人免费无遮挡大片| 在线亚洲激情| 亚洲精品视频一区| 精品9999| 国产在线乱码一区二区三区| 欧美午夜无遮挡| 欧美日韩直播| 欧美日本国产一区| 欧美99久久| 久久亚洲精品欧美| 久久九九热re6这里有精品| 亚洲一区国产一区| 一区二区三区蜜桃网| 亚洲精品视频在线观看网站| 亚洲福利视频在线| 免费欧美网站| 蜜臀av一级做a爰片久久| 久久精品国产亚洲一区二区三区| 亚洲欧美日韩中文视频| 中文在线资源观看网站视频免费不卡 | 国产一区二区三区奇米久涩| 欧美性片在线观看| 欧美性大战久久久久久久蜜臀| 欧美日韩精品一区二区天天拍小说| 欧美成人精品在线| 欧美大片免费久久精品三p| 模特精品在线| 欧美久久99| 国产精品激情电影| 国产日韩综合| 黄色精品免费| 亚洲高清自拍| 日韩视频一区二区三区在线播放免费观看 | avtt综合网| 亚洲午夜av在线| 午夜一区二区三区不卡视频| 欧美在线不卡| 麻豆精品传媒视频| 亚洲国产精品va在线观看黑人| 亚洲高清自拍| 一区二区日韩精品| 欧美一区二区三区视频| 久久久噜噜噜久噜久久| 欧美国产一区在线| 国产精品久久久免费| 狠狠爱www人成狠狠爱综合网 | 欧美日韩卡一卡二| 国产目拍亚洲精品99久久精品| 国内偷自视频区视频综合| 亚洲国产另类久久精品| 一区二区动漫| 久久精品国产一区二区三区| 美日韩精品免费观看视频| 91久久精品网| 亚洲欧美美女| 欧美高清视频在线播放| 国产精品一区免费观看| 亚洲成色777777在线观看影院| 99精品福利视频| 久久久爽爽爽美女图片| 亚洲国产精品一区制服丝袜 | 亚洲一区亚洲| 免费欧美在线| 国产精品制服诱惑| **网站欧美大片在线观看| 在线亚洲高清视频| 免费观看30秒视频久久| 亚洲图中文字幕| 欧美刺激午夜性久久久久久久| 国产精品亚洲а∨天堂免在线| 91久久线看在观草草青青| 欧美一区日韩一区| 亚洲欧洲另类| 久久五月激情| 国产亚洲激情| 午夜精品久久久久久久久久久久| 亚洲成色777777在线观看影院| 亚洲免费在线电影| 欧美偷拍一区二区| 日韩一级免费观看| 欧美大片一区二区| 欧美一区二区成人| 国产精品午夜视频|