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