我用 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/