Qt 5.10 Book Examples
chapter34
ToolBar
MainWindow.h
Go to the documentation of this file.
1
// ======================================================================
2
// MainWindow.h
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
#pragma once
12
13
#include <QtWidgets>
14
15
// ======================================================================
16
class
MainWindow
:
public
QMainWindow {
17
Q_OBJECT
18
public
:
19
MainWindow
(QWidget* pwgt = 0) : QMainWindow(pwgt)
20
{
21
addToolBar(Qt::TopToolBarArea,
createToolBar
());
22
addToolBar(Qt::BottomToolBarArea,
createToolBar
());
23
addToolBar(Qt::LeftToolBarArea,
createToolBar
());
24
addToolBar(Qt::RightToolBarArea,
createToolBar
());
25
}
26
27
QToolBar*
createToolBar
()
28
{
29
QToolBar* ptb =
new
QToolBar(
"Linker ToolBar"
);
30
31
ptb->addAction(QPixmap(
":/img1.png"
),
"1"
,
this
, SLOT(
slotNoImpl
()));
32
ptb->addAction(QPixmap(
":/img2.png"
),
"2"
,
this
, SLOT(
slotNoImpl
()));
33
ptb->addSeparator();
34
ptb->addAction(QPixmap(
":/img3.png"
),
"3"
,
this
, SLOT(
slotNoImpl
()));
35
ptb->addAction(QPixmap(
":/img4.png"
),
"4"
,
this
, SLOT(
slotNoImpl
()));
36
37
return
ptb;
38
}
39
40
public
slots:
41
void
slotNoImpl
()
42
{
43
QMessageBox::information(0,
"Message"
,
"Not implemented"
);
44
}
45
};
MainWindow::MainWindow
MainWindow(QWidget *pwgt=0)
Definition:
MainWindow.h:19
MainWindow::createToolBar
QToolBar * createToolBar()
Definition:
MainWindow.h:27
MainWindow::slotNoImpl
void slotNoImpl()
Definition:
MainWindow.h:41
MainWindow
Definition:
MainWindow.h:16
Generated by
1.8.14