Obsolete Members for <QtAlgorithms>

The following members of class <QtAlgorithms> are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

Functions

LessThan qGreater() (obsolete)
LessThan qLess() (obsolete)
void qSwap(T & var1, T & var2) (obsolete)

Function Documentation

LessThan qGreater()

Use std::greater instead.

Returns a functional object, or functor, that can be passed to qSort() or qStableSort().

Example:

QList<int> list;
list << 33 << 12 << 68 << 6 << 12;
qSort(list.begin(), list.end(), qGreater<int>());
// list: [ 68, 33, 12, 12, 6 ]

See also qLess<T>().

LessThan qLess()

Use std::less instead.

Returns a functional object, or functor, that can be passed to qSort() or qStableSort().

Example:

QList<int> list;
list << 33 << 12 << 68 << 6 << 12;
qSort(list.begin(), list.end(), qLess<int>());
// list: [ 6, 12, 12, 33, 68 ]

See also qGreater<T>().

void qSwap(T & var1, T & var2)

Use std::swap instead.

Exchanges the values of variables var1 and var2.

Example:

double pi = 3.14;
double e = 2.71;

qSwap(pi, e);
// pi == 2.71, e == 3.14