QPair Class
The QPair class is a template class that stores a pair of items. More...
Header: | #include <QPair> |
qmake: | QT += core |
Public Types
typedef | first_type |
typedef | second_type |
Public Functions
QPair() | |
QPair(const T1 & value1, const T2 & value2) | |
QPair(const QPair<TT1, TT2> & p) | |
QPair(QPair<TT1, TT2> && p) | |
void | swap(QPair & other) |
QPair & | operator=(const QPair<TT1, TT2> & p) |
QPair & | operator=(QPair<TT1, TT2> && p) |
Public Variables
Detailed Description
The QPair class is a template class that stores a pair of items.
QPair<T1, T2> can be used in your application if the STL pair
type is not available. It stores one value of type T1 and one value of type T2. It can be used as a return value for a function that needs to return two values, or as the value type of a generic container.
Here's an example of a QPair that stores one QString and one double
value:
QPair<QString, double> pair;
The components are accessible as public data members called first and second. For example:
pair.first = "pi"; pair.second = 3.14159265358979323846;
QPair's template data types (T1 and T2) must be assignable data types. You cannot, for example, store a QWidget as a value; instead, store a QWidget *. A few functions have additional requirements; these requirements are documented on a per-function basis.
See also Container Classes.
Member Type Documentation
typedef QPair::first_type
The type of the first element in the pair (T1).
See also first.
typedef QPair::second_type
The type of the second element in the pair (T2).
See also second.
Member Function Documentation
QPair::QPair()
Constructs an empty pair. The first
and second
elements are initialized with default-constructed values.
QPair::QPair(const T1 & value1, const T2 & value2)
Constructs a pair and initializes the first
element with value1 and the second
element with value2.
See also qMakePair().