https://www.jianshu.com/p/5b2387137e3a?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
https://www.cnblogs.com/mikedong/p/7204092.html
- 通过mac的homebrew安装qt
brew install qt
此步骤安装完成后,终端会显示安装完成后的最终目录/usr/local/opt/qt
- 下载并安装qtcreator
使用homebrew
brew install qt-creator
或者
选择需要的版本下载即可
http://download.qt.io/official_releases/qtcreator/
- 配置
上面两条命令之间是没有关联的,后装的qt-creator不会自动检测到前面的qt(qt这个包是QT开发工具链),所以需要配置。
通过brew info qt
命令,查看详情
swaedeMacBook-Pro:projects swae$ brew info qt
qt: stable 5.11.2 (bottled), HEAD [keg-only]
Cross-platform application and UI framework
https://www.qt.io/
/usr/local/Cellar/qt/5.11.2 (9,502 files, 304.3MB)
Poured from bottle on 2018-10-29 at 22:00:58
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/qt.rb
==> Dependencies
Build: pkg-config ✔
Optional: mysql-client ✘, postgresql ✘
==> Requirements
Build: Xcode ✔
==> Options
--with-examples
Build examples
--with-mysql-client
Build with mysql-client support
--with-postgresql
Build with postgresql support
--without-proprietary-codecs
Don't build with proprietary codecs (e.g. mp3)
--HEAD
Install HEAD version
==> Caveats
We agreed to the Qt open source license for you.
If this is unacceptable you should uninstall.
qt is keg-only, which means it was not symlinked into /usr/local,
because Qt 5 has CMake issues when linked.
If you need to have qt first in your PATH run:
echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile
For compilers to find qt you may need to set:
export LDFLAGS="-L/usr/local/opt/qt/lib"
export CPPFLAGS="-I/usr/local/opt/qt/include"
For pkg-config to find qt you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/qt/lib/pkgconfig"
==> Analytics
install: 32,552 (30 days), 87,950 (90 days), 402,650 (365 days)
install_on_request: 14,540 (30 days), 40,226 (90 days), 181,203 (365 days)
build_error: 0 (30 days)
问题
-
安装完成后,创建新的项目出现错误
No valid kits found.
,
原因: qtcreator 无法选择Qt版本导致,此时我们需要添加qt版本。
解决方法: 打开qtcreator的偏好设置-Kits-QT versions,点击添加,找到/usr/local/Cellar/qt/5.11.2/bin/qmake
文件,添加进去,然后在构建套件的QT 版本选项选择添加的版本即可。 -
运行项目后报错 Project ERROR: failed to parse default search paths from compiler output.
解决方法: 打开qtcreator的偏好设置-Kits,在构建套件(kit)选项栏,选中桌面
,将编译器由gcc修改编译器为Clang。
作者:多网
链接:https://www.jianshu.com/p/5b2387137e3a
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。