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
src_gui_widgets_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 BSD-3-Clause
3
5
void
Widget::mousePressEvent
(
QMouseEvent
*
event
)
6
{
7
origin =
event
->pos();
8
if
(!rubberBand)
9
rubberBand =
new
QRubberBand
(
QRubberBand::Rectangle
,
this
);
10
rubberBand->setGeometry(
QRect
(origin,
QSize
()));
11
rubberBand->show();
12
}
13
14
void
Widget::mouseMoveEvent
(
QMouseEvent
*
event
)
15
{
16
rubberBand->setGeometry(
QRect
(origin,
event
->pos()).
normalized
());
17
}
18
19
void
Widget::mouseReleaseEvent
(
QMouseEvent
*
event
)
20
{
21
rubberBand->hide();
22
// determine selection, for example using QRect::intersects()
23
// and QRect::contains().
24
}
QMouseEvent
\inmodule QtGui
Definition
qevent.h:196
QRect
\inmodule QtCore\reentrant
Definition
qrect.h:30
QRect::normalized
QRect normalized() const noexcept
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
Definition
qrect.cpp:277
QRubberBand
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
Definition
qrubberband.h:18
QRubberBand::Rectangle
@ Rectangle
Definition
qrubberband.h:22
QSize
\inmodule QtCore
Definition
qsize.h:25
QWidget::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition
qwidget.cpp:9461
QWidget::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition
qwidget.cpp:9483
QWidget::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition
qwidget.cpp:9508
event
struct _cl_event * event
Definition
qopenglext.h:2998
qtbase
src
widgets
doc
snippets
code
src_gui_widgets_qrubberband.cpp
Generated by
1.10.0