Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquickuniversalfocusrectangle.cpp
Go to the documentation of this file.
1
// Copyright (C) 2017 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
// Qt-Security score:significant reason:default
4
5
#
include
"qquickuniversalfocusrectangle_p.h"
6
7
#
include
<
QtGui
/
qpixmap
.
h
>
8
#
include
<
QtGui
/
qpainter
.
h
>
9
#
include
<
QtGui
/
qpixmapcache
.
h
>
10
#
include
<
QtQuick
/
private
/
qquickitem_p
.
h
>
11
12
QT_BEGIN_NAMESPACE
13
14
QQuickUniversalFocusRectangle::QQuickUniversalFocusRectangle(
QQuickItem
*
parent
)
15
:
QQuickPaintedItem
(
parent
)
16
{
17
QQuickItemPrivate::get(
this
)->setTransparentForPositioner(
true
);
18
}
19
20
void
QQuickUniversalFocusRectangle::paint(QPainter *painter)
21
{
22
if
(!isVisible() || width() <= 0 || height() <= 0)
23
return
;
24
25
QRect bounds = boundingRect().toAlignedRect();
26
const
int
boundsWidth = bounds.width();
27
const
int
boundsHeight = bounds.width();
28
const
QString key = QStringLiteral(
"qquickuniversalfocusrectangle_%1_%2"
).arg(QString::number(boundsWidth), QString::number(boundsHeight));
29
30
QPixmap pixmap(boundsWidth, boundsHeight);
31
if
(!QPixmapCache::find(key, &pixmap)) {
32
bounds.adjust(0, 0, -1, -1);
33
pixmap.fill(Qt::transparent);
34
QPainter p(&pixmap);
35
36
QPen pen;
37
pen.setWidth(1);
38
pen.setColor(Qt::white);
39
p.setPen(pen);
40
p.drawRect(bounds);
41
42
pen.setColor(Qt::black);
43
pen.setDashPattern(QList<qreal>(2, 1));
44
p.setPen(pen);
45
p.drawRect(bounds);
46
47
QPixmapCache::insert(key, pixmap);
48
}
49
painter->drawPixmap(0, 0, pixmap);
50
}
51
52
QT_END_NAMESPACE
53
54
#
include
"moc_qquickuniversalfocusrectangle_p.cpp"
QObjectData::parent
QObject * parent
Definition
qobject.h:74
QQuickItem
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition
qquickitem.h:64
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
quickcontrols
universal
impl
qquickuniversalfocusrectangle.cpp
Generated on
for Qt by
1.18.0