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.

Pick-to: 6.4
Task-number: QTBUG-105469
Change-Id: Ic6547f8247454b47baa8fffd170eb8ffc31feb5d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Thiago Macieira 2022-08-25 20:05:21 -03:00 committed by Mårten Nordheim
parent 7deb49d886
commit 15ccc7e499

View File

@ -1328,9 +1328,21 @@ void QVariant::save(QDataStream &s) const
/*!
\since 4.4
\relates QVariant
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}
*/
QDataStream &operator>>(QDataStream &s, QVariant &p)
@ -1341,6 +1353,7 @@ QDataStream &operator>>(QDataStream &s, QVariant &p)
/*!
Writes a variant \a p to the stream \a s.
\relates QVariant
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
@ -2611,9 +2624,6 @@ QT_WARNING_POP
\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()
*/