1QPair(3qt) QPair(3qt)
2
3
4
6 QPair - Value-based template class that provides a pair of elements
7
9 #include <qpair.h>
10
11 Public Members
12 typedef T1 first_type
13 typedef T2 second_type
14 QPair ()
15 QPair ( const T1 & t1, const T2 & t2 )
16 QPair<T1, T2> & operator= ( const QPair<T1, T2> & other )
17
19 QPair qMakePair ( T1 t1, T2 t2 )
20
22 The QPair class is a value-based template class that provides a pair of
23 elements.
24
25 QPair is a Qt implementation of an STL-like pair. It can be used in
26 your application if the standard pair<> is not available on your target
27 platforms.
28
29 QPair<T1, T2> defines a template instance to create a pair of values
30 that contains two values of type T1 and T2. Please note that QPair does
31 not store pointers to the two elements; it holds a copy of every
32 member. This is why these kinds of classes are called value based. If
33 you're interested in pointer based classes see, for example, QPtrList
34 and QDict.
35
36 QPair holds one copy of type T1 and one copy of type T2, but does not
37 provide iterators to access these elements. Instead, the two elements
38 (first and second) are public member variables of the pair. QPair owns
39 the contained elements. For more relaxed ownership semantics, see
40 QPtrCollection and friends which are pointer-based containers.
41
42 Some classes cannot be used within a QPair: for example, all classes
43 derived from QObject and thus all classes that implement widgets. Only
44 "values" can be used in a QPair. To qualify as a value the class must
45 provide:
46
47 A copy constructor
48
49 An assignment operator
50
51 A constructor that takes no arguments
52
53 Note that C++ defaults to field-by-field assignment operators and copy
54 constructors if no explicit version is supplied. In many cases this is
55 sufficient.
56
57 QPair uses an STL-like syntax to manipulate and address the objects it
58 contains. See the QTL documentation for more information.
59
60 Functions that need to return two values can use a QPair.
61
62 See also Qt Template Library Classes, Implicitly and Explicitly Shared
63 Classes, and Non-GUI Classes.
64
65 Member Type Documentation
67 The type of the first element in the pair.
68
70 The type of the second element in the pair.
71
74 Constructs an empty pair. The first and second elements are default
75 constructed.
76
78 Constructs a pair and initializes the first element with t1 and the
79 second element with t2.
80
83 This is a template convenience function. It is used to create a QPair<>
84 object that contains t1 and t2.
85
86
88 http://doc.trolltech.com/qpair.html
89 http://www.trolltech.com/faq/tech.html
90
92 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
93 license file included in the distribution for a complete license
94 statement.
95
97 Generated automatically from the source code.
98
100 If you find a bug in Qt, please report it as described in
101 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
102 help you. Thank you.
103
104 The definitive Qt documentation is provided in HTML format; it is
105 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
106 web browser. This man page is provided as a convenience for those users
107 who prefer man pages, although this format is not officially supported
108 by Trolltech.
109
110 If you find errors in this manual page, please report them to qt-
111 bugs@trolltech.com. Please include the name of the manual page
112 (qpair.3qt) and the Qt version (3.3.8).
113
114
115
116Trolltech AS 2 February 2007 QPair(3qt)