Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
mainwindowsnippet.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtGui>
5#include <QtWidgets>
6
7#include "include/mainwindow.h"
8
9MainWindow::MainWindow()
10{
11 createMenus();
12 createToolBars();
13 createDockWidgets();
14 //setMenuWidget(new QPushButton("Hello"));
15}
16
18{
19 //setMenuWidget(new QPushButton("Hello"));
20 QMenu *menu = new QMenu("File");
21 menu->addAction("Save &As");
22
23 QMenuBar *bar = new QMenuBar;
24 bar->addMenu(menu);
25
26 setMenuWidget(new QWidget());
27}
28
30{
31 setToolButtonStyle(Qt::ToolButtonTextOnly);
32 QToolBar *t1 = new QToolBar;
33 t1->addAction(new QAction("t1", this));
34
35 QToolBar *t2 = new QToolBar;
36 t2->addAction(new QAction("t2", this));
37
38 addToolBar(Qt::LeftToolBarArea, t1);
39 addToolBar(Qt::LeftToolBarArea, t2);
40}
41
43{
44 QWidget *dockWidgetContents = new QWidget;
45 QVBoxLayout *layout = new QVBoxLayout(dockWidgetContents);
46 layout->addWidget(new QPushButton("My Button."));
47
48 //! [0]
49 QDockWidget *dockWidget = new QDockWidget(tr("Dock Widget"), this);
50 dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea |
51 Qt::RightDockWidgetArea);
52 dockWidget->setWidget(dockWidgetContents);
53 addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
54 //! [0]
55}
void createMenus()
[0]
void createToolBars()
friend class QWidget
Definition qpainter.h:431