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
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Keith Gardner <kreios4004@gmail.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
4
5#include <QVersionNumber>
6
7class Object
8{
9public:
10 static void genericExample();
11 static void equalityExample();
12 static void isPrefixOf();
13 static void parse();
14 static void equivalent();
15};
16
18{
20 QVersionNumber version(1, 2, 3); // 1.2.3
22}
23
25{
27 QVersionNumber v1(1, 2);
28 QVersionNumber v2(1, 2, 0);
29 int compare = QVersionNumber::compare(v1, v2); // compare == -1
31}
32
34{
36 QVersionNumber v1(5, 3);
37 QVersionNumber v2(5, 3, 1);
38 bool value = v1.isPrefixOf(v2); // true
40}
41
42void QObject::parse()
43{
45 QString string("5.4.0-alpha");
46 qsizetype suffixIndex;
47 QVersionNumber version = QVersionNumber::fromString(string, &suffixIndex);
48 // version is 5.4.0
49 // suffixIndex is 5
51
53 QLatin1StringView string("5.4.0-alpha");
54 qsizetype suffixIndex;
55 auto version = QVersionNumber::fromString(string, &suffixIndex);
56 // version is 5.4.0
57 // suffixIndex is 5
59}
60
62{
64 QVersionNumber v1(5, 4);
65 QVersionNumber v2(5, 4, 0);
66 bool equivalent = v1.normalized() == v2.normalized();
67 bool equal = v1 == v2;
68 // equivalent is true
69 // equal is false
71}
72
Definition main.cpp:8
static void equivalent()
Definition main.cpp:61
static void equalityExample()
Definition main.cpp:24
static void isPrefixOf()
Definition main.cpp:33
static void parse()
static void genericExample()
Definition main.cpp:17
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
static Q_CORE_EXPORT QVersionNumber fromString(QAnyStringView string, qsizetype *suffixIndex=nullptr)
static Q_CORE_EXPORT int compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept
Compares v1 with v2 and returns an integer less than, equal to, or greater than zero,...
int main()
[0]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLfloat GLfloat GLfloat v2
GLint GLfloat GLfloat v1
GLsizei const GLchar *const * string
[0]
Definition qopenglext.h:694
#define v1
static int compare(quint64 a, quint64 b)
ptrdiff_t qsizetype
Definition qtypes.h:165
static bool equal(const QChar *a, int l, const char *b)
Definition qurlidna.cpp:338