c++ - 在 C++ 和 Qt 中,如何将这些 `#include <Q...>` 写入另外几行?

标签 c++ qt include

我用 C++ 和 Qt 编写了一些代码来创建 GUI。首先,我写了以下内容

#include <QApplication>
#include <QLabel>
#include <QPushButton>

写这几行的时候,我想起了以前用Python和Qt的时候,要用Qt类,我是这样写的。

from PyQt.Gui import *
from PyQt.GtCore import *

问题是:在 C++ 中我如何编写这些 #include <Q...>像上面的另外几行?

这是我正在使用的 .cpp 文件。

#include <QApplication>
#include <QLabel>
#include <QPushButton>

int main(int argc, char *argv[]){
  QApplication app(argc, argv);

  /* create label */
  QLabel *label = new QLabel("Hello");
  label->show();

  /* create button */
  QPushButton *button = new QPushButton("World");
  button->show();

  return app.exec();
}

这是 .pro 文件。

######################################################################
# Automatically generated by qmake (3.1) Sun Mar 19 23:12:24 2017
######################################################################

TEMPLATE = app
TARGET = cppRunOnXcode
INCLUDEPATH += .
CONFIG += debug
QT += widgets


# Input
SOURCES += cppRunOnXcode.cpp

最佳答案

您可以包含 super 标题,例如:

#include <QtWidgets>
#include <QtCore>

基本上, super header 与 Qt 模块是一对一相关的。

关于c++ - 在 C++ 和 Qt 中,如何将这些 `#include <Q...>` 写入另外几行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42971836/

相关文章:

c++ - 多组对象

c++ - Ubuntu系统中不同内容的同名 header

c++ - QFile::copy 静态函数不复制文件

android - 将值动态设置为包含 View 的 TextView

c++ - 计算斐波那契数的一般 tbb 问题

c++ - 在数组中查找最小值

python - 在 python 中使用 pytest 测试基于 QML 的应用程序

python - 我在 PySide 1.1.0 中找不到 QString

php - 如何将参数传递给使用 'include' 呈现的 PHP 模板?

php - Wordpress - 将代码片段包含到布局的选定部分中的插件