将Qtwiddgets与Qmake一起使用
Using Qtwidgets with Qmake
我正在使用qmake -project
和qmake Prog.pro
构建我的Qt应用程序。
当我运行Makefile时,我得到了这个错误:
mainwindow.h:11:21: fatal error: QtWidgets: No such file or directory
#include <QtWidgets>
我必须添加行
QT += widgets
到.pro文件进行正确编译。有没有办法自动做到这一点?
有没有办法自动做到这一点?
是和否
你可以这样运行qmake:
qmake -project "QT+=widgets"
然后它被正确地生成,但除了从命令行生成之外,没有。此外,请注意,如果你计划支持Qt4,你也希望使用一个保护:
greaterThan(QT_MAJOR_VERSION, 4):QT+=widgets
如果您碰巧使用QtCreator
,您将能够避免这一切,因为IDE将自动为您生成这一切。
此外,您应该能够避免将整个模块包含在所有类中,即使您没有全部使用它们。所以,与其写这个:
#include <QtWidgets>
你可以写:
#include <Foo>
#include <Bar>
...
相关文章:
- 如何将enable-if与模板参数和参数包一起使用
- 如何将PERF_AMPLE_READ与mmap一起使用
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 如何将C++中的库和头与MinGW一起使用
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 为什么我不能将 rand() 与数组的大小一起使用?
- 要与"if constexpr"一起使用的编译时消息(在预处理器之后)
- 不能将复制初始化与隐式转换的多个步骤一起使用
- 将fold表达式与std::一起用于两个元组
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 将 std::allocate_shared 与多态资源分配器一起使用
- 为什么常量词在重载运算符中不与 ostream 对象一起使用<<?
- 将 OpenCV 与 CMAKE 中的项目一起构建为第三方库的正确方法
- 将 exprtk 与自定义类的对象一起使用
- 将 std::set 与基于键的比较器一起使用
- qmake:检测目标位宽(32 位或 64 位)
- 使用QMake将Ubuntu中的QT和OPENCV一起编译
- 让qmake与32位和64位并行安装一起工作
- 修改 qmake 文件以构建到多个目标以与'#IFDEF macro'一起使用
- 将Qtwiddgets与Qmake一起使用