Qt安装for MAC

Qt安装for MAC

对于Mac用户,首先应下载Xcode(下载过的请忽略)

然后打开终端安装homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

好目前准备工作就算是完成了。

1.终端安装Qt

brew install qt

此步骤安装完成后,终端会显示安装完成后的最终目录
/usr/local/opt/qt

1.1下载并安装qt-creator

有两种方法

  • 使用homebrew
brew install qt-creator
  • 手动安装
    选择需要的版本下载即可
http://download.qt.io/official_releases/qtcreator/

1.3.配置

上面两条命令之间是没有关联的,后装的qt-creator不会自动检测到前面的qt(qt这个包是QT开发工具链),所以需要配置。

通过brew info qt命令,查看详情

qt: stable 5.14.0 (bottled), HEAD [keg-only]
Cross-platform application and UI framework
https://www.qt.io/
/usr/local/Cellar/qt/5.14.0 (10,381 files, 363.2MB)
  Poured from bottle on 2020-02-08 at 21:22:10
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/qt.rb
==> Dependencies
Build: pkg-config ✔
==> Requirements
Build: xcode ✔
Required: macOS >= 10.12==> Options
--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: 66,443 (30 days), 179,407 (90 days), 699,250 (365 days)
install-on-request: 18,790 (30 days), 50,254 (90 days), 192,728 (365 days)
build-error: 0 (30 days)

1.4.问题

  • 安装完成后,创建新的项目出现错误No valid kits found.,
    原因: qtcreator 无法选择Qt版本导致,此时我们需要添加qt版本。
    解决方法: 打开qtcreator的偏好设置-Kits-QT versions,点击添加,找到/usr/local/Cellar/qt/5.14.0/bin/qmake文件,添加进去,然后在构建套件的QT 版本选项选择添加的版本即可。

  • 运行项目后报错 Project ERROR: failed to parse default search paths from compiler output.
    解决方法: 打开qtcreator的偏好设置-Kits,在构建套件(kit)选项栏,选中桌面,将编译器由gcc修改编译器为Clang。

    img

2.dmg安装

2.1下载dmg

下载相应版本的qt.dmg
QT.dmg下载地址
在这里插入图片描述
选择Mac64位版本下载
在这里插入图片描述

2.2安装

下载完成后进行解压安装
在这里插入图片描述
双击打开
在这里插入图片描述
下一步
这里呢需要登陆你的QT账户
没有可以新建一个账户
在这里插入图片描述
下一步
在这里插入图片描述
点击选项,继续
这里呢,选择安装目录很重要,我们选择安装在path路径下,避免修改路径
当然也可以模拟brew安装放在/usr/local/opt/目录下
继续
在这里插入图片描述
选择安装组建,这里可以参考
在这里插入图片描述
点击选项,等待安装完成
在这里插入图片描述

2.3配置

相关配置如上1.3

  • 3
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值