注:你可能会对下面的内容感兴趣。
浅谈 qmake 之 pro、pri、prf、prl文件
浅谈 qmake 之 shadow build
qmake 之 CONFIG(debug, debug|release)
qmake 之 CONFIG 与 QT 乱谈
$$varName |
qmake工程文件内定义变量的值 |
$$(varName) |
qmake运行时,环境变量的值 |
$(varName) |
makefile被处理时,环境变量的值 |
$$[varName] |
Qt配置选项的值 |
${varName} |
你可能见过这个用法,但本文不讨论这个东西,以后用到时会提及 |
这4中用法区别何在?没有例子我还真说不明白...
例子:
projectname = dbzhang FULL1 = $$projectname/800 FULL2 = $${projectname}800 !build_pass:message($$FULL2)
运行qmake时,输出结果是
Project MESSAGE: dbzhang/800 dbzhang800
环境变量,就是大家通常说得环境变量。例子:
message($$(PATH))
运行qmake时,结果:
Project MESSAGE: /usr/bin:/home/debao/qt-labs/qt5/qtbase/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
makefile被处理时,环境变量的值?如何理解??
看例子:
INCLUDEPATH += $(MYINCLUDEPATH)
执行qmake
$ export MYINCLUDEPATH="/home/dbzhang800/include" $ qmake test.pro
生成的makefile:
... INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I$(MYINCLUDEPATH) -I. ...
为了对比,可以将单$符号,改成$$再试试看看,运行命令,结果:
... INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/home/dbzhang800/include -I. ...
Qt配置选项的值?何解??
debao@ubuntu:~/ttt/qmake-t1$ qmake -query QT_INSTALL_PREFIX:/usr QT_INSTALL_DATA:/usr/share/qt4 QT_INSTALL_DOCS:/usr/share/qt4/doc QT_INSTALL_HEADERS:/usr/include/qt4 QT_INSTALL_LIBS:/usr/lib QT_INSTALL_BINS:/usr/bin ...
win32:{ DLLDESTDIR = $$[QT_INSTALL_BINS] QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\dbzhang800.dll }
$ qmake -set dbzhang 800
然后就可以在pro文件内用 $$[dbzhang] 了
注:在Qt5下,有 qmake -unset dbzhang 可以取消设置,在Qt4下没有 unset!
注:设置值是通过QSettings保存的。你应该知道保存在何处了,呵呵
QSettings(QSettings::UserScope, "Trolltech", "QMake");
晕死,4个这东西竟然写了这么长。只好本文标题中加个(一),慢慢写二三四了。
http://developer.qt.nokia.com/wiki/Qt_Modules_Maturity_Level
http://labs.qt.nokia.com/2009/10/12/to-make-or-not-to-make-qmake-and-beyond/
http://labs.qt.nokia.com/2009/10/14/to-make-or-not-to-make-qmake-and-beyond-redux/