The QVersionNumber class contains a version number with an arbitrary number of segments. 更多...
头: | #include <QVersionNumber> |
qmake: | QT += core |
Since: | Qt 5.6 |
QVersionNumber () | |
QVersionNumber (const QVector<int> & seg ) | |
QVersionNumber (QVector<int> && seg ) | |
QVersionNumber (std::initializer_list<int> args ) | |
QVersionNumber (int maj ) | |
QVersionNumber (int maj , int min ) | |
QVersionNumber (int maj , int min , int mic ) | |
bool | isNormalized () const |
bool | isNull () const |
bool | isPrefixOf (const QVersionNumber & other ) const |
int | majorVersion () const |
int | microVersion () const |
int | minorVersion () const |
QVersionNumber | normalized () const |
int | segmentAt (int index ) const |
int | segmentCount () const |
QVector<int> | segments () const |
QString | toString () const |
QVersionNumber | commonPrefix (const QVersionNumber & v1 , const QVersionNumber & v2 ) |
int | compare (const QVersionNumber & v1 , const QVersionNumber & v2 ) |
QVersionNumber | fromString (const QString & string , int * suffixIndex = Q_NULLPTR) |
bool | operator!= (const QVersionNumber & lhs , const QVersionNumber & rhs ) |
bool | operator< (const QVersionNumber & lhs , const QVersionNumber & rhs ) |
QDataStream & | operator<< (QDataStream & out , const QVersionNumber & version ) |
bool | operator<= (const QVersionNumber & lhs , const QVersionNumber & rhs ) |
bool | operator== (const QVersionNumber & lhs , const QVersionNumber & rhs ) |
bool | operator> (const QVersionNumber & lhs , const QVersionNumber & rhs ) |
bool | operator>= (const QVersionNumber & lhs , const QVersionNumber & rhs ) |
QDataStream & | operator>> (QDataStream & in , QVersionNumber & version ) |
The QVersionNumber class contains a version number with an arbitrary number of segments.
QVersionNumber version(1, 2, 3); // 1.2.3
Produces a null version.
另请参阅 isNull ().
Constructs a version number from the list of numbers contained in seg .
Move-constructs a version number from the list of numbers contained in seg .
This constructor is only enabled if the compiler supports C++11 move semantics.
Construct a version number from the std::initializer_list specified by args .
This constructor is only enabled if the compiler supports C++11 initializer lists.
构造 QVersionNumber consisting of just the major version number maj .
构造 QVersionNumber consisting of the major and minor version numbers maj and min ,分别。
构造 QVersionNumber consisting of the major, minor, and micro version numbers maj , min and mic ,分别。
[static]
QVersionNumber
QVersionNumber::
commonPrefix
(const
QVersionNumber
&
v1
, const
QVersionNumber
&
v2
)
QVersionNumber QVersionNumber::commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2)
Returns a version number that is a parent version of both v1 and v2 .
另请参阅 isPrefixOf ().
[static]
int
QVersionNumber::
compare
(const
QVersionNumber
&
v1
, const
QVersionNumber
&
v2
)
比较 v1 with v2 and returns an integer less than, equal to, or greater than zero, depending on whether v1 is less than, equal to, or greater than v2 ,分别。
Comparisons are performed by comparing the segments of v1 and v2 starting at index 0 and working towards the end of the longer list.
QVersionNumber v1(1, 2); QVersionNumber v2(1, 2, 0); int compare = QVersionNumber::compare(v1, v2); // compare == -1
[static]
QVersionNumber
QVersionNumber::
fromString
(const
QString
&
string
,
int
*
suffixIndex
= Q_NULLPTR)
构造
QVersionNumber
from a specially formatted
string
of non-negative decimal numbers delimited by a period (
.
).
Once the numerical segments have been parsed, the remainder of the string is considered to be the suffix string. The start index of that string will be stored in suffixIndex if it is not null.
QString string("5.4.0-alpha"); int suffixIndex; QVersionNumber version = QVersionNumber::fromString(string, &suffixIndex); // version is 5.4.0 // suffixIndex is 5
另请参阅 isNull ().
返回
true
if the version number does not contain any trailing zeros, otherwise returns
false
.
另请参阅 normalized ().
返回
true
if there are zero numerical segments, otherwise returns
false
.
另请参阅 segments ().
返回
true
if the current version number is contained in the
other
version number, otherwise returns
false
.
QVersionNumber v1(5, 3); QVersionNumber v2(5, 3, 1); bool value = v1.isPrefixOf(v2); // true
另请参阅 commonPrefix ().
Returns the major version number, that is, the first segment. This function is equivalent to segmentAt (0). If this QVersionNumber object is null, this function returns 0.
另请参阅 isNull () 和 segmentAt ().
Returns the micro version number, that is, the third segment. This function is equivalent to segmentAt (2). If this QVersionNumber object does not contain a micro number, this function returns 0.
另请参阅 isNull () 和 segmentAt ().
Returns the minor version number, that is, the second segment. This function is equivalent to segmentAt (1). If this QVersionNumber object does not contain a minor number, this function returns 0.
另请参阅 isNull () 和 segmentAt ().
Returns an equivalent version number but with all trailing zeros removed.
To check if two numbers are equivalent, use normalized() on both version numbers before performing the compare.
QVersionNumber v1(5, 4); QVersionNumber v2(5, 4, 0); bool equivalent = v1.normalized() == v2.normalized(); bool equal = v1 == v2; // equivalent is true // equal is false
Returns the segement value at index . If the index does not exist, returns 0.
另请参阅 segments () 和 segmentCount ().
Returns the number of integers stored in segments ().
另请参阅 segments ().
Returns all of the numerical segments.
另请参阅 majorVersion (), minorVersion (),和 microVersion ().
Returns a string with all of the segments delimited by a period (
.
).
另请参阅 majorVersion (), minorVersion (), microVersion (),和 segments ().
返回
true
if
lhs
不等于
rhs
;否则返回
false
.
另请参阅 QVersionNumber::compare ().
返回
true
if
lhs
小于
rhs
;否则返回
false
.
另请参阅 QVersionNumber::compare ().
Writes the version number version 到流 out .
Note that this has nothing to do with QDataStream::version ().
返回
true
if
lhs
<=
rhs
;否则返回
false
.
另请参阅 QVersionNumber::compare ().
返回
true
if
lhs
等于
rhs
;否则返回
false
.
另请参阅 QVersionNumber::compare ().
返回
true
if
lhs
大于
rhs
;否则返回
false
.
另请参阅 QVersionNumber::compare ().
返回
true
if
lhs
>=
rhs
;否则返回
false
.
另请参阅 QVersionNumber::compare ().
Reads a version number from stream in and stores it in version .
Note that this has nothing to do with QDataStream::version ().