QVersionNumber

The QVersionNumber class contains a version number with an arbitrary number of segments. More

Inheritance diagram of PySide6.QtCore.QVersionNumber

New in version 5.6.

Synopsis

Functions

Static functions

Detailed Description

version = QVersionNumber(1, 2, 3)
class PySide6.QtCore.QVersionNumber

PySide6.QtCore.QVersionNumber(seg)

PySide6.QtCore.QVersionNumber(seg)

PySide6.QtCore.QVersionNumber(maj)

PySide6.QtCore.QVersionNumber(maj, min)

PySide6.QtCore.QVersionNumber(maj, min, mic)

Parameters
  • seg

  • maj – int

  • min – int

  • mic – int

Produces a null version.

See also

isNull()

Constructs a QVersionNumber consisting of just the major version number maj.

Constructs a QVersionNumber consisting of the major and minor version numbers maj and min, respectively.

Constructs a QVersionNumber consisting of the major, minor, and micro version numbers maj, min and mic, respectively.

PySide6.QtCore.QVersionNumber.enum_245
static PySide6.QtCore.QVersionNumber.commonPrefix(v1, v2)
Parameters
Return type

PySide6.QtCore.QVersionNumber

QVersionNumber (const QVersionNumber &v1, const QVersionNumber &v2)

Returns a version number that is a parent version of both v1 and v2.

See also

isPrefixOf()

static PySide6.QtCore.QVersionNumber.compare(v1, v2)
Parameters
Return type

int

Compares 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, respectively.

Comparisons are performed by comparing the segments of v1 and v2 starting 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 PySide6.QtCore.QVersionNumber.fromString(string[, suffixIndex=None])
Parameters
  • stringQStringView

  • suffixIndex – int

Return type

PySide6.QtCore.QVersionNumber

This is an overloaded function.

Constructs a QVersionNumber from a specially formatted string of non-negative decimal numbers delimited by ‘.’.

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.

string = QString("5.4.0-alpha")
suffixIndex = int()
version = QVersionNumber.fromString(string, suffixIndex)
# version is 5.4.0
# suffixIndex is 5

See also

isNull()

static PySide6.QtCore.QVersionNumber.fromString(string)
Parameters

string – str

Return type

PySide6.QtCore.QVersionNumber

Constructs a 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.

string = QString("5.4.0-alpha")
suffixIndex = int()
version = QVersionNumber.fromString(string, suffixIndex)
# version is 5.4.0
# suffixIndex is 5

See also

isNull()

PySide6.QtCore.QVersionNumber.isNormalized()
Return type

bool

Returns true if the version number does not contain any trailing zeros, otherwise returns false.

See also

normalized()

PySide6.QtCore.QVersionNumber.isNull()
Return type

bool

Returns true if there are zero numerical segments, otherwise returns false.

See also

segments()

PySide6.QtCore.QVersionNumber.isPrefixOf(other)
Parameters

otherPySide6.QtCore.QVersionNumber

Return type

bool

Returns true if the current version number is contained in the other version number, otherwise returns false.

v1 = QVersionNumber(5, 3)
v2 = QVersionNumber(5, 3, 1)
value = v1.isPrefixOf(v2) # true

See also

commonPrefix()

PySide6.QtCore.QVersionNumber.majorVersion()
Return type

int

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.

PySide6.QtCore.QVersionNumber.microVersion()
Return type

int

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.

PySide6.QtCore.QVersionNumber.minorVersion()
Return type

int

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.

PySide6.QtCore.QVersionNumber.normalized()
Return type

PySide6.QtCore.QVersionNumber

Returns an equivalent version number but with all trailing zeros removed.

To check if two numbers are equivalent, use 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
PySide6.QtCore.QVersionNumber.__ne__(rhs)
Parameters

rhsPySide6.QtCore.QVersionNumber

Return type

bool

PySide6.QtCore.QVersionNumber.__lt__(rhs)
Parameters

rhsPySide6.QtCore.QVersionNumber

Return type

bool

PySide6.QtCore.QVersionNumber.__le__(rhs)
Parameters

rhsPySide6.QtCore.QVersionNumber

Return type

bool

PySide6.QtCore.QVersionNumber.__eq__(rhs)
Parameters

rhsPySide6.QtCore.QVersionNumber

Return type

bool

PySide6.QtCore.QVersionNumber.__gt__(rhs)
Parameters

rhsPySide6.QtCore.QVersionNumber

Return type

bool

PySide6.QtCore.QVersionNumber.__ge__(rhs)
Parameters

rhsPySide6.QtCore.QVersionNumber

Return type

bool

PySide6.QtCore.QVersionNumber.segmentAt(index)
Parameters

index – int

Return type

int

Returns the segment value at index. If the index does not exist, returns 0.

PySide6.QtCore.QVersionNumber.segmentCount()
Return type

int

Returns the number of integers stored in segments() .

See also

segments()

PySide6.QtCore.QVersionNumber.segments()
Return type

Returns all of the numerical segments.

PySide6.QtCore.QVersionNumber.toString()
Return type

str

Returns a string with all of the segments delimited by a period (.).