QPartialOrdering Class

QPartialOrdering represents the result of a comparison that allows for unordered results. More...

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

Static Public Members

const QPartialOrdering Equivalent
const QPartialOrdering Greater
const QPartialOrdering Less
const QPartialOrdering Unordered
bool operator!=(QPartialOrdering p1, QPartialOrdering p2)
bool operator==(QPartialOrdering p1, QPartialOrdering p2)

Detailed Description

A value of type QPartialOrdering is typically returned from a three-way comparison function. Such a function compares two objects, and it may either establish that the two objects are ordered relative to each other, or that they are not ordered. The QPartialOrdering value returned from the comparison function represents one of those possibilities.

The possible values of type QPartialOrdering are, in fact, fully represented by the following four static values:

  • QPartialOrdering::Less represents that the first object is less than the second;
  • QPartialOrdering::Equivalent represents that the first object is equivalent to the second;
  • QPartialOrdering::Greater represents that the first object is equivalent to the second;
  • QPartialOrdering::Unordered represents that the first object is not ordered with respect to the second.

QPartialOrdering is idiomatically used by comparing an instance against a literal zero, for instance like this:

// given a, b, c, d as objects of some type that allows for a 3-way compare

QPartialOrdering result = a.compare(b);
if (result < 0) {
    // a is less than b
}

if (c.compare(d) >= 0) {
    // c is greater than or equal to d
}

A QPartialOrdering value which represents an unordered result will always return false when compared against literal 0.

Member Variable Documentation

const QPartialOrdering QPartialOrdering::Equivalent

Represents the result of a comparison where the value on the left hand side is equivalent to the value on right hand side.

const QPartialOrdering QPartialOrdering::Greater

Represents the result of a comparison where the value on the left hand side is greater than the value on right hand side.

const QPartialOrdering QPartialOrdering::Less

Represents the result of a comparison where the value on the left hand side is less than the value on right hand side.

const QPartialOrdering QPartialOrdering::Unordered

Represents the result of a comparison where the value on the left hand side is not ordered with respect to the value on right hand side.

Related Non-Members

bool operator!=(QPartialOrdering p1, QPartialOrdering p2)

Return true if p1 and p2 represent different results; otherwise, returns true.

bool operator==(QPartialOrdering p1, QPartialOrdering p2)

Return true if p1 and p2 represent the same result; otherwise, returns false.

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.