- Qt 6.9
- Qt Core
- C++ Classes
- QTypeRevision
- Qt 6.9.3 Reference Documentation

# QTypeRevision Class

The QTypeRevision class contains a lightweight representation of a version number with two 8-bit segments, major and minor, either of which can be unknown. More...

Header: | `#include <QTypeRevision>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Core)` `target_link_libraries(mytarget PRIVATE Qt6::Core)`
qmake: | `QT += core`
Since: | Qt 6.0

- List of all members, including inherited members

This class is strongly comparable.

## Public Functions

| QTypeRevision()
bool | hasMajorVersion() const
bool | hasMinorVersion() const
bool | isValid() const
quint8 | majorVersion() const
quint8 | minorVersion() const
Integer | toEncodedVersion() const

## Static Public Members

QTypeRevision | fromEncodedVersion(Integer value)
QTypeRevision | fromMajorVersion(Major majorVersion)
QTypeRevision | fromMinorVersion(Minor minorVersion)
QTypeRevision | fromVersion(Major majorVersion, Minor minorVersion)
bool | isValidSegment(Integer segment)
QTypeRevision | zero()

## Related Non-Members

`(since 6.0)` QDataStream & | operator<<(QDataStream &out, const QTypeRevision &revision)
`(since 6.0)` QDataStream & | operator>>(QDataStream &in, QTypeRevision &revision)

## Detailed Description

Use this class to describe revisions of a type. Compatible revisions can be expressed as increments of the minor version. Breaking changes can be expressed as increments of the major version. The return values of QMetaMethod::revision() and QMetaProperty::revision() can be passed to QTypeRevision::fromEncodedVersion(). The resulting major and minor versions specify in which Qt versions the properties and methods were added.

See also QMetaMethod::revision() and QMetaProperty::revision().

## Member Function Documentation

### `[constexpr noexcept]` QTypeRevision::QTypeRevision()

Produces an invalid revision.

See also isValid().

### `[static constexpr]` template <typename Integer, QTypeRevision::if_valid_value_type<Integer> = true> QTypeRevision QTypeRevision::fromEncodedVersion(Integer value)

Produces a QTypeRevision from the given value. value encodes both the minor and major versions in the least significant and second least significant byte, respectively.

value must not have any bits outside the least significant two bytes set. `Integer` needs to be at least 16 bits wide, and must not have a sign bit in the least significant 16 bits.

See also toEncodedVersion().

### `[static constexpr]` template <typename Major, QTypeRevision::if_valid_segment_type<Major> = true> QTypeRevision QTypeRevision::fromMajorVersion(Major majorVersion)

Produces a QTypeRevision from the given majorVersion with an invalid minor version. majorVersion needs to be a valid segment.

See also isValidSegment().

### `[static constexpr]` template <typename Minor, QTypeRevision::if_valid_segment_type<Minor> = true> QTypeRevision QTypeRevision::fromMinorVersion(Minor minorVersion)

Produces a QTypeRevision from the given minorVersion with an invalid major version. minorVersion needs to be a valid segment.

See also isValidSegment().

### `[static constexpr]` template <typename Major, typename Minor, QTypeRevision::if_valid_segment_type<Major> = true, QTypeRevision::if_valid_segment_type<Minor> = true> QTypeRevision QTypeRevision::fromVersion(Major majorVersion, Minor minorVersion)

Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a valid segments.

See also isValidSegment().

### `[constexpr]` bool QTypeRevision::hasMajorVersion() const

Returns true if the major version is known, otherwise false.

See also majorVersion() and hasMinorVersion().

### `[constexpr]` bool QTypeRevision::hasMinorVersion() const

Returns true if the minor version is known, otherwise false.

See also minorVersion() and hasMajorVersion().

### `[constexpr]` bool QTypeRevision::isValid() const

Returns true if the major version or the minor version is known, otherwise false.

See also hasMajorVersion() and hasMinorVersion().

### `[static constexpr]` template <typename Integer, QTypeRevision::if_valid_segment_type<Integer> = true> bool QTypeRevision::isValidSegment(Integer segment)

Returns true if the given number can be used as either major or minor version in a QTypeRevision. The valid range for segment is `>= 0` and `< 255`.

### `[constexpr]` quint8 QTypeRevision::majorVersion() const

Returns the major version encoded in the revision.

See also hasMajorVersion() and minorVersion().

### `[constexpr]` quint8 QTypeRevision::minorVersion() const

Returns the minor version encoded in the revision.

See also hasMinorVersion() and majorVersion().

### `[constexpr]` template <typename Integer, QTypeRevision::if_valid_value_type<Integer> = true> Integer QTypeRevision::toEncodedVersion() const

Transforms the revision into an integer value, encoding the minor version into the least significant byte, and the major version into the second least significant byte.

`Integer` needs to be at least 16 bits wide, and must not have a sign bit in the least significant 16 bits.

See also fromEncodedVersion().

### `[static constexpr]` QTypeRevision QTypeRevision::zero()

Produces a QTypeRevision with major and minor version `0`.

## Related Non-Members

### `[since 6.0]` QDataStream &operator<<(QDataStream &out, const QTypeRevision &revision)

Writes the revision revision to stream out.

This function was introduced in Qt 6.0.

### `[since 6.0]` QDataStream &operator>>(QDataStream &in, QTypeRevision &revision)

Reads a revision from stream in and stores it in revision.

This function was introduced in Qt 6.0.