Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qrubberband.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QRUBBERBAND_H
5#define QRUBBERBAND_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qwidget.h>
9
11
13
15class QStyleOptionRubberBand;
16
17class Q_WIDGETS_EXPORT QRubberBand : public QWidget
18{
20
21public:
22 enum Shape { Line, Rectangle };
23 explicit QRubberBand(Shape, QWidget * = nullptr);
25
26 Shape shape() const;
27
28 void setGeometry(const QRect &r);
29
30 inline void setGeometry(int x, int y, int w, int h);
31 inline void move(int x, int y);
32 inline void move(const QPoint &p)
33 { move(p.x(), p.y()); }
34 inline void resize(int w, int h)
35 { setGeometry(geometry().x(), geometry().y(), w, h); }
36 inline void resize(const QSize &s)
37 { resize(s.width(), s.height()); }
38
39protected:
40 bool event(QEvent *e) override;
41 void paintEvent(QPaintEvent *) override;
42 void changeEvent(QEvent *) override;
43 void showEvent(QShowEvent *) override;
44 void resizeEvent(QResizeEvent *) override;
45 void moveEvent(QMoveEvent *) override;
46 virtual void initStyleOption(QStyleOptionRubberBand *option) const;
47
48private:
49 Q_DECLARE_PRIVATE(QRubberBand)
50};
51
52inline void QRubberBand::setGeometry(int ax, int ay, int aw, int ah)
53{ setGeometry(QRect(ax, ay, aw, ah)); }
54inline void QRubberBand::move(int ax, int ay)
55{ setGeometry(ax, ay, width(), height()); }
56
58
59#endif // QRUBBERBAND_H
\inmodule QtCore
Definition qcoreevent.h:45
The QMoveEvent class contains event parameters for move events.
Definition qevent.h:501
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:485
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:547
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
Definition qrubberband.h:18
Shape
This enum specifies what shape a QRubberBand should have.
Definition qrubberband.h:22
void move(const QPoint &p)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrubberband.h:32
void move(int x, int y)
Moves the rubberband to point (x, y).
Definition qrubberband.h:54
void setGeometry(const QRect &r)
Sets the geometry of the rubber band to rect, specified in the coordinate system of its parent widget...
void resize(int w, int h)
Resizes the rubberband so that its width is width, and its height is height.
Definition qrubberband.h:34
void resize(const QSize &s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrubberband.h:36
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:577
\inmodule QtCore
Definition qsize.h:25
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:886
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition qwidget.h:106
int width
the width of the widget excluding any window frame
Definition qwidget.h:114
void move(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:880
virtual void moveEvent(QMoveEvent *event)
This event handler can be reimplemented in a subclass to receive widget move events which are passed ...
Definition qwidget.cpp:9847
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
int y
the y coordinate of the widget relative to its parent and including any window frame
Definition qwidget.h:110
int x
the x coordinate of the widget relative to its parent including any window frame
Definition qwidget.h:109
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9428
void resize(int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:883
virtual void resizeEvent(QResizeEvent *event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition qwidget.cpp:9868
virtual void paintEvent(QPaintEvent *event)
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwidget.cpp:9829
virtual void showEvent(QShowEvent *event)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
double e
Combined button and popup list for selecting options.
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean r
[2]
GLint y
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLuint GLenum option
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT