path: root/src/corelib/tools/qpair.qdoc
diff options
authorMarc Mutz <>2016-01-04 22:39:46 +0100
committerMarc Mutz <>2016-01-05 10:25:05 +0000
commit01d8abdbf1bdeed9efe706318c5798c4f1e9b104 (patch)
tree9b6333c1b08992193fba1d6683799cd59f804992 /src/corelib/tools/qpair.qdoc
parenta3ce1235493622e51aa872511ea80081f9e96805 (diff)
[docs] Gently steer people away from QPair
Change-Id: Ib0fb69f856606612d516426732f619422630c93f Reviewed-by: Friedemann Kleint <> Reviewed-by: Lars Knoll <>
Diffstat (limited to 'src/corelib/tools/qpair.qdoc')
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index 7cba7480f0..cc0aa731fb 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -48,6 +48,18 @@
\snippet code/doc_src_qpair.cpp 1
+ Note, however, that it is almost always preferable to define a small struct
+ to hold the result of a function with multiple return values. A struct
+ trivially generalizes to more than two values, and allows more descriptive
+ member names than \c{first} and \c{second}:
+ \snippet code/doc_src_qpair.cpp struct
+ The advent of C++11 automatic variable type deduction (\c{auto}) shifts the
+ emphasis from the type name to the name of functions and members. Thus, QPair,
+ like \c{std::pair} and \c{std::tuple}, is mostly useful in generic (template)
+ code, where defining a dedicated type is not possible.
QPair's template data types (T1 and T2) must be \l{assignable
data types}. You cannot, for example, store a QWidget as a value;
instead, store a QWidget *. A few functions have additional