【问题标题】:I cannot use Qt with CLion我不能将 Qt 与 CLion 一起使用
【发布时间】:2021-05-01 18:49:33
【问题描述】:

我尝试在 CLion 中使用 Qt 制作程序。 在 CLion 的启动窗口中单击 New Project 后,我​​选择左侧的 Qt Widgets Executable 并添加以下 Qt CMake 前缀路径:

C:\Qt\6.0.3

然后我点击“创建”并获得“打开项目向导”窗口。我单击“管理工具链...”并添加一个新工具链。在“环境:”旁边我写:

C:\Qt\Tools\mingw810_64

一切看起来都很好。然后我点击确定,然后再次点击确定,几秒钟后我收到以下消息:

CMake Error at CMakeLists.txt:21 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" with any of
  the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.

拜托,你能帮帮我吗? (我的电脑上安装了Qt)

【问题讨论】:

  • Qt 6 相当新,可能 CLion(尤其是随附的 CMake 版本)还没有添加对它的支持。
  • 即使使用 Qt 5 也无法正常工作。
  • 从实际错误消息的第一行开始:“通过在 CMAKE_MODULE_PATH 中不提供“FindQt5.cmake”...”(强调我的)。您需要找到Qt的CMake配置文件的位置,并将该位置添加到环境变量CMAKE_MODULE_PATH

标签: c++ windows-10 qt5 c++14 clion


【解决方案1】:

尝试以前版本的 qt

试试 Visual Studio IDE。

【讨论】:

  • 我可以使用 QtCreator,但它不如 CLion 先进。同样使用 Visual Studio,让 Qt 工作很痛苦
【解决方案2】:
  1. 设置工具链,默认qt mingw工具路径
  2. 创建qt项目时,请设置qt cmake前缀路径,如“D:\Qt\6.1.2\mingw81_64\lib\cmake”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-26
    • 2017-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    相关资源
    最近更新 更多