QVariant/Doc: document that you must register types before op>>
But not before ::fromValue, since that registers automatically. Take the opportunity to add the \relates to the two streaming operators to QDataStream, so the documentation shows up *somewhere* at all. Task-number: QTBUG-105469 Change-Id: Ic6547f8247454b47baa8fffd170eb8ffc31feb5d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 15ccc7e499ac8dd1f75dfa75346d15c4b4d06324) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
69084cf721
commit
0ad99e39df
@ -1312,9 +1312,21 @@ void QVariant::save(QDataStream &s) const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.4
|
\since 4.4
|
||||||
|
\relates QVariant
|
||||||
|
|
||||||
Reads a variant \a p from the stream \a s.
|
Reads a variant \a p from the stream \a s.
|
||||||
|
|
||||||
|
\note If the stream contains types that aren't the built-in ones (see \l
|
||||||
|
QMetaType::Type), those types must be registered using qRegisterMetaType()
|
||||||
|
or QMetaType::registerType() before the variant can be properly loaded. If
|
||||||
|
an unregistered type is found, QVariant will set the corrupt flag in the
|
||||||
|
stream, stop processing and print a warning. For example, for QList<int>
|
||||||
|
it would print the following:
|
||||||
|
|
||||||
|
\quotation
|
||||||
|
QVariant::load: unknown user type with name QList<int>
|
||||||
|
\endquotation
|
||||||
|
|
||||||
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
|
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
|
||||||
*/
|
*/
|
||||||
QDataStream &operator>>(QDataStream &s, QVariant &p)
|
QDataStream &operator>>(QDataStream &s, QVariant &p)
|
||||||
@ -1325,6 +1337,7 @@ QDataStream &operator>>(QDataStream &s, QVariant &p)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Writes a variant \a p to the stream \a s.
|
Writes a variant \a p to the stream \a s.
|
||||||
|
\relates QVariant
|
||||||
|
|
||||||
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
|
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
|
||||||
*/
|
*/
|
||||||
@ -2595,9 +2608,6 @@ QT_WARNING_POP
|
|||||||
|
|
||||||
\snippet code/src_corelib_kernel_qvariant.cpp 7
|
\snippet code/src_corelib_kernel_qvariant.cpp 7
|
||||||
|
|
||||||
\note If you are working with custom types, you should use
|
|
||||||
the Q_DECLARE_METATYPE() macro to register your custom type.
|
|
||||||
|
|
||||||
\sa setValue(), value()
|
\sa setValue(), value()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user