Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qrubberband.cpp
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#include "qbitmap.h"
5#include "qevent.h"
6#include "qstylepainter.h"
7#include "qrubberband.h"
8#include "qtimer.h"
9
10#include "qstyle.h"
11#include "qstyleoption.h"
12
13#include <qdebug.h>
14
15#include <private/qwidget_p.h>
16
18
19//### a rubberband window type would be a more elegant solution
20#define RUBBERBAND_WINDOW_TYPE Qt::ToolTip
21
23{
24 Q_DECLARE_PUBLIC(QRubberBand)
25public:
29 void updateMask();
30};
31
39void QRubberBand::initStyleOption(QStyleOptionRubberBand *option) const
40{
41 if (!option)
42 return;
43 option->initFrom(this);
44 option->shape = d_func()->shape;
45#ifndef Q_OS_MAC
46 option->opaque = true;
47#else
49#endif
50}
51
84// ### DOC: How about some nice convenience constructors?
85//QRubberBand::QRubberBand(QRubberBand::Type t, const QRect &rect, QWidget *p)
86//QRubberBand::QRubberBand(QRubberBand::Type t, int x, int y, int w, int h, QWidget *p)
87
107
114
137{
138 Q_D(const QRubberBand);
139 return d->shape;
140}
141
146{
147 Q_Q(QRubberBand);
149 QStyleOptionRubberBand opt;
150 q->initStyleOption(&opt);
151 if (q->style()->styleHint(QStyle::SH_RubberBand_Mask, &opt, q, &mask)) {
152 q->setMask(mask.region);
153 } else {
154 q->clearMask();
155 }
156}
157
162{
164 QStyleOptionRubberBand option;
167}
168
173{
175 switch (e->type()) {
177 if (parent()) {
179 } else {
181 }
182 break;
183 default:
184 break;
185 }
186
187 if (e->type() == QEvent::ZOrderChange)
188 raise();
189}
190
195{
196 raise();
197 e->ignore();
198}
199
204{
205 Q_D(QRubberBand);
206 d->updateMask();
207}
208
213{
214 Q_D(QRubberBand);
215 d->updateMask();
216}
217
264{
266}
267
279{
280 return QWidget::event(e);
281}
282
284
285#include "moc_qrubberband.cpp"
\inmodule QtCore
Definition qcoreevent.h:45
@ ParentChange
Definition qcoreevent.h:80
@ ZOrderChange
Definition qcoreevent.h:173
Type type() const
Returns the event type.
Definition qcoreevent.h:304
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition qcoreevent.h:311
The QMoveEvent class contains event parameters for move events.
Definition qevent.h:502
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
QRubberBand::Shape shape
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 resizeEvent(QResizeEvent *) override
\reimp
virtual void initStyleOption(QStyleOptionRubberBand *option) const
Initialize option with the values from this QRubberBand.
void moveEvent(QMoveEvent *) override
\reimp
void paintEvent(QPaintEvent *) override
\reimp
bool event(QEvent *e) override
\reimp
Shape shape() const
Returns the shape of this rubber band.
void changeEvent(QEvent *) override
\reimp
void setGeometry(const QRect &r)
Sets the geometry of the rubber band to rect, specified in the coordinate system of its parent widget...
void showEvent(QShowEvent *) override
\reimp
~QRubberBand()
Destructor.
QRubberBand(Shape, QWidget *=nullptr)
Constructs a rubber band of shape s, with parent p.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
The QStyleHintReturnMask class provides style hints that return a QRegion.
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
@ SH_RubberBand_Mask
Definition qstyle.h:639
@ CE_RubberBand
Definition qstyle.h:209
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
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
void raise()
Raises this widget to the top of the parent widget's stack.
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.g.
Definition qwidget.h:803
virtual void setVisible(bool visible)
Definition qwidget.cpp:8255
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9382
bool event(QEvent *event) override
This is the main event handler; it handles event event.
Definition qwidget.cpp:8866
void setWindowFlags(Qt::WindowFlags type)
QStyleOptionButton opt
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ WA_WState_ExplicitShowHide
Definition qnamespace.h:335
@ WA_TransparentForMouseEvents
Definition qnamespace.h:317
@ WA_NoSystemBackground
Definition qnamespace.h:291
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLdouble s
[6]
Definition qopenglext.h:235
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
GLuint GLenum option
#define RUBBERBAND_WINDOW_TYPE
QPainter painter(this)
[7]