Mac下brew安装和配置Qt5的坑与解决办法

1. 安装PyQt5:

brew install qt
brew cask install qt-creator

2 然后在 Qt Creator 里改一下 Qt Versions的坑: 参考知乎boyu的回答

    2.1 偏好设置-Kits-Qt Versions-添加路径/usr/local/Cellar/qt/5.11.2/bin/qmake

        Mac下brew安装和配置Qt5的坑与解决办法_第1张图片

    2.2 偏好设置-Kits-构建套件(Kit)-手动设置-桌面(默认)-Qt版本-Qt 5.11.2

        Mac下brew安装和配置Qt5的坑与解决办法_第2张图片

3 创建项目(Project)的坑: 参考《QT Creator 两种创建项目的方法》

    方法之一:
    先建项目:欢迎-New Project-其他项目-Empty qmake Project => 一路默认就建好了一个项目了
    再添加CPP文件:在项目上右键-Add  New...-C++-C++源文件 => 一路默认,如果报错解决方法如下:

    3.1 报错:解决办法参考《Mac下用brew配置QT开发环境》

Project ERROR: failed to parse default search paths from compiler output
Error while parsing file /Users/hanpeizhi/Qt5/testProject01/testProject01.pro. Giving up.

        把编译器C和C++全部改为Clang

         Mac下brew安装和配置Qt5的坑与解决办法_第3张图片

    3.2 报错:解决办法参考知乎boyu回答中的评论

Project WARNING: Qt has only been tested with version 10.13 of the platform SDK, you're using 10.13.4.
Project WARNING: This is an unsupported configuration. You may experience build issues, and by using
Project WARNING: the 10.13.4 SDK you are opting in to new features that Qt has not been prepared for.
Project WARNING: Please downgrade the SDK you use to build your app to version 10.13, or configure
Project WARNING: with CONFIG+=sdk_no_version_check when running qmake to silence this warning.

        打开终端输入命令: 

xcode-select -p

        因为我已经安装了Xcode了,所以直接在输入(如果还没安装就先去App Store安装):

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

        如下:

$ xcode-select -p
/Library/Developer/CommandLineTools

$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

        

 

 

====
目前我就遇到这些坑,所以就写这么多。
另外安装和配置PyQt5参考:《Mac下Pycharm集成PyQt5并使用》
PyQt + PyCharm 环境搭建:《PyQt5+python3+pycharm开发环境配置》
====
感谢几位网友的帮助和分析!
====

 

你可能感兴趣的:(PyQt入门,Qt5,PyQt5)