转载自:http://shitou7630.blog.163.com/blog/static/3269953620161126105156562/
1、解决方案1
QT_ARCH326432-biti386
contains(QT_ARCH, i386) {
2、解决方案2
貌似也有人用QMAKE_TARGET.arch进行判断,但是可能只适用windows,不适合跨平台。
win32 {
## Windows common build here
QMAKE_HOST.arch, x86_64) {
## Windows x86 (32bit) specific build here
## Windows x64 (64bit) specific build here
}
3、解决方案3
利用自定义的字符变量进行判断。
Qt allows you to pass arbitrary config parameters which you can use to separate the targets.
By having a conditional config in your project file:
CONFIG(myX64, myX64|myX32) {
} else {
}
qmake CONFIG+=myX64
you get the wanted result.
4、解决方案4
#Firstly,Set TARGET_ARCH variable.
greaterThan(QT_MAJOR_VERSION, 4) { TARGET_ARCH=$${QT_ARCH} } else { TARGET_ARCH=$${QMAKE_HOST.arch} } #Secondly, use TARGET_ARCH to check. contains(TARGET_ARCH, x86_64) { ARCHITECTURE = x64 } else { ARCHITECTURE = x86 }
文章来源: Qt的pro文件里如何判断系统是32位或64位