【问题标题】:Qt Cannot open include file: 'QPrinter'Qt 无法打开包含文件:'QPrinter'
【发布时间】:2013-10-09 08:36:39
【问题描述】:

我是 Qt 的新手。下载 SourceForge 的 Qt 应用程序的源代码,并尝试构建和运行它。通过在 .pro 文件中添加 QT += 语句解决了一些类似的问题后,我被困在这个问题上:

在尝试构建 Qt Creator 时,我收到错误提示

错误:C1083:无法打开包含文件:'QPrinter':没有这样的文件或目录

我尝试将 QT += printsupport 添加到 .pro 文件中,进行清理和重建,但出现此错误

错误:依赖 '..\..\..\..\..\..\..\..\..\..\..\Qt\Qt5.1.1\5.1.1\ msvc2012_64\include\QtPrintSupport\qtprintsupportglobal.h' 不存在。”

当我转到C:\Qt\Qt5.1.1\5.1.1\msvc2012_64\include\QtPrintSupport 时,qtprintsupportglobal.h 就在那里!

【问题讨论】:

  • 没有我需要编辑的项目特定路径,是吗?
  • 删除影子构建目录并重新构建,以防万一。

标签: qt include qmake


【解决方案1】:

您必须在项目的 .pro 文件中添加 QPrinter 支持:

QT += printsupport

【讨论】:

    【解决方案2】:

    在我的情况下,解决方案是

    删除影子构建目录并重新构建

    添加 printsupport,正如 @KubaOber 在 cmets 中所建议的那样。

    【讨论】:

      【解决方案3】:

      容易犯的错误:编辑您的 .pro 之后

      QT       += printsupport
      

      您必须先保存文件,然后您的 .h 才会知道它。

      【讨论】:

        【解决方案4】:

        因为 QMake 最终会被 CMake 取代,所以这里是 CMake 用户的解决方案:

        PrintSupport 传递给find_package 调用,传递到COMPONENTS 的右侧,如下例所示:

        find_package(Qt5 ${QT5_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControls2 PrintSupport)
        

        【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-07
        • 1970-01-01
        相关资源
        最近更新 更多