Qt 5.10 Book Examples
chapter14
ResizeEvent
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
class
ResizeObserver
:
public
QLabel {
15
public
:
16
ResizeObserver
(QWidget* pwgt = 0) : QLabel(pwgt)
17
{
18
setAlignment(Qt::AlignCenter);
19
}
20
21
protected
:
22
virtual
void
resizeEvent
(QResizeEvent* pe)
23
{
24
setText(QString(
"Resized"
)
25
+
"\n width()="
+ QString::number(pe->size().width())
26
+
"\n height()="
+ QString::number(pe->size().height())
27
);
28
}
29
};
30
31
// ----------------------------------------------------------------------
32
int
main
(
int
argc,
char
** argv)
33
{
34
QApplication app(argc, argv);
35
ResizeObserver
wgt;
36
37
wgt.resize(250, 130);
38
wgt.show();
39
40
return
app.exec();
41
}
42
ResizeObserver::resizeEvent
virtual void resizeEvent(QResizeEvent *pe)
Definition:
main.cpp:22
ResizeObserver
Definition:
main.cpp:14
main
int main(int argc, char **argv)
Definition:
main.cpp:15
ResizeObserver::ResizeObserver
ResizeObserver(QWidget *pwgt=0)
Definition:
main.cpp:16
Generated by
1.8.14