Qt 5.10 Book Examples
chapter31
Menu
main.cpp
Go to the documentation of this file.
1
// ======================================================================
2
// main.cpp
3
// ======================================================================
4
// This file is a part of the book
5
// "Qt 5.10 Professional programming with C++"
6
// http://qt-book.com
7
// ======================================================================
8
// Copyright (c) 2017 by Max Schlee
9
// ======================================================================
10
11
#include <QtWidgets>
12
13
// ----------------------------------------------------------------------
14
int
main
(
int
argc,
char
** argv)
15
{
16
QApplication app(argc, argv);
17
18
QMenuBar mnuBar;
19
QMenu* pmnu =
new
QMenu(
"&Menu"
);
20
21
pmnu->addAction(
"&About Qt"
,
22
&app,
23
SLOT(aboutQt()),
24
Qt::CTRL + Qt::Key_Q
25
);
26
27
pmnu->addSeparator();
28
29
QAction* pCheckableAction = pmnu->addAction(
"&CheckableItem"
);
30
pCheckableAction->setCheckable(
true
);
31
pCheckableAction->setChecked(
true
);
32
33
pmnu->addAction(QPixmap(
":/img4.png"
),
"&IconItem"
);
34
35
QMenu* pmnuSubMenu =
new
QMenu(
"&SubMenu"
, pmnu);
36
pmnu->addMenu(pmnuSubMenu);
37
pmnuSubMenu->addAction(
"&Test"
);
38
39
QAction* pDisabledAction = pmnu->addAction(
"&DisabledItem"
);
40
pDisabledAction->setEnabled(
false
);
41
42
pmnu->addSeparator();
43
44
pmnu->addAction(
"&Exit"
, &app, SLOT(quit()));
45
46
mnuBar.addMenu(pmnu);
47
mnuBar.show();
48
49
return
app.exec();
50
}
main
int main(int argc, char **argv)
Definition:
main.cpp:15
Generated by
1.8.14