1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTVERSIONCHECKS_H
#define QTVERSIONCHECKS_H
#if 0
#pragma qt_class(QtVersionChecks)
#pragma qt_sync_stop_processing
#endif
#include <QtCore/qtconfiginclude.h>
/*
QT_VERSION is (major << 16) | (minor << 8) | patch.
*/
#define QT_VERSION QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
*/
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
/*
Helper macros to make some simple code active in Qt 6 or Qt 7 only,
like:
struct QT6_ONLY(Q_CORE_EXPORT) QTrivialClass
{
void QT7_ONLY(Q_CORE_EXPORT) void operate();
}
*/
#if QT_VERSION_MAJOR == 7 || defined(QT_BOOTSTRAPPED)
# define QT7_ONLY(...) __VA_ARGS__
# define QT6_ONLY(...)
#elif QT_VERSION_MAJOR == 6
# define QT7_ONLY(...)
# define QT6_ONLY(...) __VA_ARGS__
#else
# error Qt major version not 6 or 7
#endif
/* Macro and tag type to help overload resolution on functions
that are, e.g., QT_REMOVED_SINCE'ed. Example use:
#if QT_CORE_REMOVED_SINCE(6, 4)
int size() const;
#endif
qsizetype size(QT6_DECL_NEW_OVERLOAD) const;
in the normal cpp file:
qsizetype size(QT6_IMPL_NEW_OVERLOAD) const {
~~~
}
in removed_api.cpp:
int size() const { return int(size(QT6_CALL_NEW_OVERLOAD)); }
*/
#ifdef Q_QDOC
# define QT6_DECL_NEW_OVERLOAD
# define QT6_DECL_NEW_OVERLOAD_TAIL
# define QT6_IMPL_NEW_OVERLOAD
# define QT6_IMPL_NEW_OVERLOAD_TAIL
# define QT6_CALL_NEW_OVERLOAD
# define QT6_CALL_NEW_OVERLOAD_TAIL
#else
# define QT6_DECL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t = Qt::Disambiguated)
# define QT6_DECL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_DECL_NEW_OVERLOAD)
# define QT6_IMPL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t)
# define QT6_IMPL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_IMPL_NEW_OVERLOAD)
# define QT6_CALL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated)
# define QT6_CALL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_CALL_NEW_OVERLOAD)
#endif
/*
Macro to tag Tech Preview APIs.
It expands to nothing, because we want to use it in places where
nothing is generally allowed (not even an attribute); for instance:
to tag other macros, Q_PROPERTY declarations, and so on.
Still: use it as if it were an C++ attribute.
To mark a class as TP:
class QT_TECH_PREVIEW_API Q_CORE_EXPORT QClass { ... };
To mark a function:
QT_TECH_PREVIEW_API void qFunction();
To mark an enumeration or enumerator:
enum class QT_TECH_PREVIEW_API QEnum {
Enum1,
Enum2 QT_TECH_PREVIEW_API,
};
To mark parts of a class:
class QClass : public QObject
{
// Q_OBJECT omitted d/t QTBUG-123229
QT_TECH_PREVIEW_API
Q_PROPERTY(int countNG ...) // this is TP
Q_PROPERTY(int count ...) // this is stable API
public:
QT_TECH_PREVIEW_API
void f(); // TP
void g(); // stable
};
*/
#define QT_TECH_PREVIEW_API
#endif /* QTVERSIONCHECKS_H */
|