Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
6
#include "mainwindow.h"
7
8
MainWindow::MainWindow
()
9
{
10
createMenus();
11
createToolBars();
12
createDockWidgets();
13
//setMenuWidget(new QPushButton("Hello"));
14
}
15
16
void
MainWindow::createMenus()
17
{
18
//setMenuWidget(new QPushButton("Hello"));
19
QMenu
*
menu
=
new
QMenu
(
"File"
);
20
menu
->
addAction
(
"Save &As"
);
21
22
QMenuBar
*bar =
new
QMenuBar
;
23
bar->
addMenu
(
menu
);
24
25
setMenuWidget(
new
QWidget
());
26
}
27
28
void
MainWindow::createToolBars()
29
{
30
setToolButtonStyle
(
Qt::ToolButtonTextOnly
);
31
QToolBar
*
t1
=
new
QToolBar
;
32
t1
->
addAction
(
new
QAction
(
"t1"
,
this
));
33
34
QToolBar
*
t2
=
new
QToolBar
;
35
t2
->addAction(
new
QAction
(
"t2"
,
this
));
36
37
addToolBar(
Qt::LeftToolBarArea
,
t1
);
38
addToolBar(
Qt::LeftToolBarArea
,
t2
);
39
}
40
41
void
MainWindow::createDockWidgets()
42
{
43
QWidget
*dockWidgetContents =
new
QWidget
;
44
QVBoxLayout
*
layout
=
new
QVBoxLayout
(dockWidgetContents);
45
layout
->
addWidget
(
new
QPushButton
(
"My Button."
));
46
48
QDockWidget
*
dockWidget
=
new
QDockWidget
(
tr
(
"Dock Widget"
),
this
);
49
dockWidget
->
setAllowedAreas
(
Qt::LeftDockWidgetArea
|
50
Qt::RightDockWidgetArea
);
51
dockWidget
->
setWidget
(dockWidgetContents);
52
addDockWidget(
Qt::LeftDockWidgetArea
,
dockWidget
);
54
}
MainWindow::MainWindow
MainWindow()
[17]
Definition
src_corelib_kernel_qobject.cpp:63
QAction
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition
qaction.h:30
QDockWidget
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition
qdockwidget.h:20
QDockWidget::setAllowedAreas
void setAllowedAreas(Qt::DockWidgetAreas areas)
Definition
qdockwidget.cpp:1479
QDockWidget::setWidget
void setWidget(QWidget *widget)
Sets the widget for the dock widget to widget.
Definition
qdockwidget.cpp:1385
QLayout::addWidget
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
Definition
qlayout.cpp:186
QMainWindow::setToolButtonStyle
void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)
Definition
qmainwindow.cpp:440
QMenuBar
The QMenuBar class provides a horizontal menu bar.
Definition
qmenubar.h:20
QMenuBar::addMenu
QAction * addMenu(QMenu *menu)
Appends menu to the menu bar.
Definition
qmenubar.cpp:768
QMenu
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition
qmenu.h:26
QMenu::addAction
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition
qwidget.cpp:3117
QObject::QWidget
friend class QWidget
Definition
qobject.h:382
QToolBar
The QToolBar class provides a movable panel that contains a set of controls.
Definition
qtoolbar.h:23
QToolBar::addAction
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition
qwidget.cpp:3117
QVBoxLayout
The QVBoxLayout class lines up widgets vertically.
Definition
qboxlayout.h:91
QWidget
The QWidget class is the base class of all user interface objects.
Definition
qwidget.h:99
QWidget::layout
QLayout * layout() const
Returns the layout manager that is installed on this widget, or \nullptr if no layout manager is inst...
Definition
qwidget.cpp:10209
QPushButton
QPushButton
[1]
Definition
common-mistakes.cpp:5
Qt::RightDockWidgetArea
@ RightDockWidgetArea
Definition
qnamespace.h:1198
Qt::LeftDockWidgetArea
@ LeftDockWidgetArea
Definition
qnamespace.h:1197
Qt::LeftToolBarArea
@ LeftToolBarArea
Definition
qnamespace.h:1214
Qt::ToolButtonTextOnly
@ ToolButtonTextOnly
Definition
qnamespace.h:1440
t1
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
Definition
qopengles2ext.h:2707
t2
#define t2
Definition
qt_mips_asm_dsp_p.h:33
tr
#define tr(X)
Definition
qtemporaryfile.cpp:21
dockWidget
QDockWidget * dockWidget
[0]
Definition
src_gui_widgets_qdockwidget.cpp:5
menu
QMenu menu
[5]
Definition
src_gui_widgets_qmenu.cpp:35
qtbase
src
widgets
doc
snippets
mainwindowsnippet.cpp
Generated by
1.10.0