Coverage Report

Created: 2026-03-12 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/kernel/qcursor.h
Line
Count
Source
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
// Qt-Security score:significant reason:default
4
5
#ifndef QCURSOR_H
6
#define QCURSOR_H
7
8
#include <QtGui/qtguiglobal.h>
9
#include <QtCore/qpoint.h>
10
#include <QtGui/qwindowdefs.h>
11
#include <QtGui/qbitmap.h>
12
13
QT_BEGIN_NAMESPACE
14
15
16
class QVariant;
17
class QScreen;
18
19
/*
20
  ### The fake cursor has to go first with old qdoc.
21
*/
22
#ifdef QT_NO_CURSOR
23
24
class Q_GUI_EXPORT QCursor
25
{
26
public:
27
    static QPoint pos();
28
    static QPoint pos(const QScreen *screen);
29
    static void setPos(int x, int y);
30
    static void setPos(QScreen *screen, int x, int y);
31
    inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
32
private:
33
    QCursor();
34
};
35
36
#endif // QT_NO_CURSOR
37
38
#ifndef QT_NO_CURSOR
39
40
class QCursorData;
41
class QBitmap;
42
class QPixmap;
43
44
45
class Q_GUI_EXPORT QCursor
46
{
47
public:
48
    QCursor();
49
    QCursor(Qt::CursorShape shape);
50
    QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1);
51
    explicit QCursor(const QPixmap &pixmap, int hotX=-1, int hotY=-1);
52
    QCursor(const QCursor &cursor);
53
    ~QCursor();
54
    QCursor &operator=(const QCursor &cursor);
55
0
    QCursor(QCursor &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
56
    QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCursor)
57
58
0
    void swap(QCursor &other) noexcept { qt_ptr_swap(d, other.d); }
59
60
    operator QVariant() const;
61
62
    Qt::CursorShape shape() const;
63
    void setShape(Qt::CursorShape newShape);
64
65
#if QT_DEPRECATED_SINCE(6, 0)
66
    QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
67
0
    QBitmap bitmap(Qt::ReturnByValueConstant) const { return bitmap(); }
68
    QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
69
0
    QBitmap mask(Qt::ReturnByValueConstant) const { return mask(); }
70
#endif // QT_DEPRECATED_SINCE(6, 0)
71
    QBitmap bitmap() const;
72
    QBitmap mask() const;
73
74
    QPixmap pixmap() const;
75
    QPoint hotSpot() const;
76
77
    static QPoint pos();
78
    static QPoint pos(const QScreen *screen);
79
    static void setPos(int x, int y);
80
    static void setPos(QScreen *screen, int x, int y);
81
0
    inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
82
0
    inline static void setPos(QScreen *screen, const QPoint &p) { setPos(screen, p.x(), p.y()); }
83
84
private:
85
    friend Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept;
86
0
    friend inline bool operator!=(const QCursor &lhs, const QCursor &rhs) noexcept { return !(lhs == rhs); }
87
    QCursorData *d;
88
};
89
Q_DECLARE_SHARED(QCursor)
90
91
/*****************************************************************************
92
  QCursor stream functions
93
 *****************************************************************************/
94
#ifndef QT_NO_DATASTREAM
95
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &outS, const QCursor &cursor);
96
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &inS, QCursor &cursor);
97
#endif
98
99
#ifndef QT_NO_DEBUG_STREAM
100
Q_GUI_EXPORT QDebug operator<<(QDebug, const QCursor &);
101
#endif
102
103
#endif // QT_NO_CURSOR
104
105
QT_END_NAMESPACE
106
107
#endif // QCURSOR_H