PySide6.QtCore.QVersionNumber¶
- class QVersionNumber¶
The
QVersionNumberclass contains a version number with an arbitrary number of segments.Details
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
QVersionNumber version(1, 2, 3) # 1.2.3
Synopsis¶
Methods¶
def
__init__()def
isNormalized()def
isNull()def
isPrefixOf()def
majorVersion()def
microVersion()def
minorVersion()def
normalized()def
__ne__()def
__lt__()def
__le__()def
__eq__()def
__gt__()def
__ge__()def
segmentAt()def
segmentCount()def
segments()def
toString()
Static functions¶
def
commonPrefix()def
compare()def
fromString()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- class enum_263¶
- __init__()¶
Produces a null version.
See also
- __init__(maj)
- Parameters:
maj – int
Constructs a
QVersionNumberconsisting of just the major version numbermaj.- __init__(maj, min)
- Parameters:
maj – int
min – int
Constructs a
QVersionNumberconsisting of the major and minor version numbersmajandmin, respectively.- __init__(maj, min, mic)
- Parameters:
maj – int
min – int
mic – int
Constructs a
QVersionNumberconsisting of the major, minor, and micro version numbersmaj,minandmic, respectively.- static commonPrefix(v1, v2)¶
- Parameters:
v1 –
QVersionNumberv2 –
QVersionNumber
- Return type:
QVersionNumberQVersionNumber::commonPrefix(constQVersionNumber&v1, constQVersionNumber&v2)Returns a version number that is a parent version of both
v1andv2.See also
- static compare(v1, v2)¶
- Parameters:
v1 –
QVersionNumberv2 –
QVersionNumber
- Return type:
int
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
Compares
v1withv2and returns an integer less than, equal to, or greater than zero, depending on whetherv1is less than, equal to, or greater thanv2, respectively.Comparisons are performed by comparing the segments of
v1andv2starting at index 0 and working towards the end of the longer list.v1 = QVersionNumber(1, 2) v2 = QVersionNumber(1, 2, 0) compare = QVersionNumber.compare(v1, v2) # compare == -1()
- static fromString(string)¶
- Parameters:
string – str
- Return type:
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
Constructs a
QVersionNumberfrom a specially formattedstringof 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
suffixIndexif it is not null.string = QLatin1StringView("5.4.0-alpha") suffixIndex = qsizetype() version = QVersionNumber.fromString(string, suffixIndex) # version is 5.4.0 # suffixIndex is 5
Note
In versions prior to Qt 6.4, this function was overloaded for
QString,QLatin1StringViewandQStringViewinstead, andsuffixIndexwas anint*.See also
- isNormalized()¶
- Return type:
bool
Returns
trueif the version number does not contain any trailing zeros, otherwise returnsfalse.See also
- isNull()¶
- Return type:
bool
Returns
trueif there are zero numerical segments, otherwise returnsfalse.See also
- isPrefixOf(other)¶
- Parameters:
other –
QVersionNumber- Return type:
bool
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
Returns
trueif the current version number is contained in theotherversion number, otherwise returnsfalse.v1 = QVersionNumber(5, 3) v2 = QVersionNumber(5, 3, 1) value = v1.isPrefixOf(v2) # true
See also
- majorVersion()¶
- Return type:
int
Returns the major version number, that is, the first segment. This function is equivalent to
segmentAt(0). If thisQVersionNumberobject is null, this function returns 0.See also
- microVersion()¶
- Return type:
int
Returns the micro version number, that is, the third segment. This function is equivalent to
segmentAt(2). If thisQVersionNumberobject does not contain a micro number, this function returns 0.See also
- minorVersion()¶
- Return type:
int
Returns the minor version number, that is, the second segment. This function is equivalent to
segmentAt(1). If thisQVersionNumberobject does not contain a minor number, this function returns 0.See also
- normalized()¶
- Return type:
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
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.
v1 = QVersionNumber(5, 4) v2 = QVersionNumber(5, 4, 0) equivalent = v1.normalized() == v2.normalized() equal = v1 == v2 # equivalent is true # equal is false
- __ne__(rhs)¶
- Parameters:
rhs –
QVersionNumber- Return type:
bool
Returns
trueiflhsis not equal torhs; otherwise returnsfalse.See also
- __lt__(rhs)¶
- Parameters:
rhs –
QVersionNumber- Return type:
bool
Returns
trueiflhsis less thanrhs; otherwise returnsfalse.See also
- __le__(rhs)¶
- Parameters:
rhs –
QVersionNumber- Return type:
bool
Returns
trueiflhsis less than or equal torhs; otherwise returnsfalse.See also
- __eq__(rhs)¶
- Parameters:
rhs –
QVersionNumber- Return type:
bool
Returns
trueiflhsis equal torhs; otherwise returnsfalse.See also
- __gt__(rhs)¶
- Parameters:
rhs –
QVersionNumber- Return type:
bool
Returns
trueiflhsis greater thanrhs; otherwise returnsfalse.See also
- __ge__(rhs)¶
- Parameters:
rhs –
QVersionNumber- Return type:
bool
Returns
trueiflhsis greater than or equal torhs; otherwise returnsfalse.See also
- segmentAt(index)¶
- Parameters:
index – int
- Return type:
int
Returns the segment value at
index. If the index does not exist, returns 0.See also
- segmentCount()¶
- Return type:
int
Returns the number of integers stored in
segments().See also
- segments()¶
- Return type:
.list of int
Returns all of the numerical segments.
See also
- toString()¶
- Return type:
str
Returns a string with all of the segments delimited by a period (
.).