Qt 5.10 Book Examples
Progress.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // Progress.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 #include "Progress.h"
13 
14 // ----------------------------------------------------------------------
15 Progress::Progress(QWidget* pwgt/*= 0*/)
16  : QWidget(pwgt)
17  , m_nStep(0)
18 {
19  m_pprb = new QProgressBar;
20  m_pprb->setRange(0, 5);
21  m_pprb->setMinimumWidth(200);
22  m_pprb->setAlignment(Qt::AlignCenter);
23 
24  QPushButton* pcmdStep = new QPushButton("&Step");
25  QPushButton* pcmdReset = new QPushButton("&Reset");
26 
27  QObject::connect(pcmdStep, SIGNAL(clicked()), SLOT(slotStep()));
28  QObject::connect(pcmdReset, SIGNAL(clicked()), SLOT(slotReset()));
29 
30  //Layout setup
31  QHBoxLayout* phbxLayout = new QHBoxLayout;
32  phbxLayout->addWidget(m_pprb);
33  phbxLayout->addWidget(pcmdStep);
34  phbxLayout->addWidget(pcmdReset);
35  setLayout(phbxLayout);
36 }
37 
38 // ----------------------------------------------------------------------
40 {
41  m_pprb->setValue(++m_nStep);
42 }
43 
44 // ----------------------------------------------------------------------
46 {
47  m_nStep = 0;
48  m_pprb->reset();
49 }
void slotStep()
Definition: Progress.cpp:39
void slotReset()
Definition: Progress.cpp:45
Progress(QWidget *pobj=0)
Definition: Progress.cpp:15