问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
-
- MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
- , ui(new Ui::MainWindow)
- {
- ui->setupUi(this);
- //---------菜单栏 主窗口中只存在一个
- QMenuBar* menuBar = new QMenuBar;
- this->setMenuBar(menuBar);
- QMenu* menu = menuBar->addMenu("文件");
- QAction* act = menu->addAction("打开");
- menu->addAction("新建");
- menuBar->addMenu("编辑");
- //--------工具栏
- QToolBar * toolBar = new QToolBar;
- this->addToolBar(toolBar);
- toolBar->addAction("编辑");
- }
-
- MainWindow::~MainWindow()
- {
- delete ui;
- }
-
运行结果及报错内容
mainwindow.cpp:17:30: error: allocation of incomplete type 'QToolBar'
qmainwindow.h:57:7: note: forward declaration of 'QToolBar'