macos 如何在 Mac OS X 上检查安装的 Qt 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7912896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to check the installed Qt version on Mac OS X
提问by Jeffrey
Is there a command to check the version of the installed Qt on Mac OS X. My Mac OS X version is 10.6.7.
是否有命令可以检查 Mac OS X 上安装的 Qt 版本。我的 Mac OS X 版本是 10.6.7。
Eidt: Update the status 10/28/2011
Eidt:更新状态 10/28/2011
When running /usr/sbin/system_profiler SPFrameworksDataType, the version of the QTkit is 7.6.6.
运行 /usr/sbin/system_profiler SPFrameworksDataType 时,QTkit 的版本为 7.6.6。
The value of the macro QT_VERSION_STR in qglobal.h is "4.7.2".
qglobal.h 中的宏 QT_VERSION_STR 的值为“4.7.2”。
I'm confused why the two version strings are different? Obviously, the version string "4.7.2" is what I want.
我很困惑为什么两个版本字符串不同?显然,版本字符串“4.7.2”就是我想要的。
Thanks, Jeffrey
谢谢,杰弗里
采纳答案by Robin
IF you speak about programming here...: At compile time you can check Qt's version with QT_VERSION_STR
. During runtime you can use qVersion()
. Obviously, the version you build you application with does not always match the version you run it with.
如果您在这里谈论编程...:在编译时,您可以使用QT_VERSION_STR
. 在运行时,您可以使用qVersion()
. 显然,您构建应用程序的版本并不总是与您运行它的版本相匹配。
回答by BarryMode
If you installed with brew, just do...
如果您使用 brew 安装,只需执行...
brew info qt
or
brew info qt5
brew info qt
或者
brew info qt5
Update:
更新:
Doing it this way will cut out all the extra stuff and only show versions.
这样做会减少所有额外的东西,只显示版本。
brew list --versions qt
or
brew list --versions qt5
brew list --versions qt
或者
brew list --versions qt5
Here's a nice cheatsheet for brew, btw: http://ricostacruz.com/cheatsheets/homebrew.html
这是一个很好的 brew 备忘单,顺便说一句:http: //ricostacruz.com/cheatsheets/homebrew.html
回答by Erik
Go to your "Applications>>Tools" folder and launch the System-Profiler. Look at "Software>>Frameworks>>QTKit". There you will find the version.
转到您的“应用程序>>工具”文件夹并启动System-Profiler。查看“软件>>框架>>QTKit”。在那里你会找到版本。
To get in in a terminal (to use it from Java for example) execute the following command:
要进入终端(例如从 Java 使用它),请执行以下命令:
/usr/sbin/system_profiler SPFrameworksDataType
There you will find something like this:
在那里你会发现这样的事情:
QTKit:
Version: 7.7
Last Modified: 13.04.11 16:02
Kind: Universal
64-Bit (Intel): Yes
Get Info String: QTKit 7.7, Copyright 2003-2011, Apple Inc.
Location: /System/Library/Frameworks/QTKit.framework
Private: No
In XCode there should be an environment-variable available.
在 XCode 中,应该有一个可用的环境变量。
回答by Thiago Gouvea
On terminal:
在终端:
qmake -v
qmake -v
It should return versions of QMake and Qt.
它应该返回 QMake 和 Qt 的版本。
Something like:
就像是:
QMake version 3.0
Using Qt version 5.6.2 in /Users/thiago/anaconda/lib
QMake version 3.0
Using Qt version 5.6.2 in /Users/thiago/anaconda/lib
回答by Tom Anderson
If you can find where Qt's headers are installed, qglobal.h
contains a define for QT_VERSION_STR
. You can simply grep for that.
如果您能找到 Qt 头文件的安装位置,则qglobal.h
包含QT_VERSION_STR
. 你可以简单地grep。
回答by PopcornKing
cd to the include directory where your qt headers are located and then...
cd 到您的 qt 头文件所在的包含目录,然后...
grep --include=\*.h -rnw ./ -e "QT_VERSION_STR"
which should output something like...
应该输出类似......
./QtCore/qglobal.h:40:#define QT_VERSION_STR "5.4.2"
./QtCore/qglobal.h:40:#define QT_VERSION_STR "5.4.2"
回答by bleater
If installed via brew, this will get the version into the variable QT_VERSION
如果通过 brew 安装,这会将版本放入变量中 QT_VERSION
QT_VERSION=`brew list --versions qt5 | sed -En -e 's/qt ([0-9._]+).*//p'`
You can then invoke it thusly:
然后你可以这样调用它:
/usr/local/Cellar/qt/${QT_VERSION}/bin/qmake