diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-08-25 20:05:21 -0300 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2022-08-26 18:32:15 +0000 |
commit | 15ccc7e499ac8dd1f75dfa75346d15c4b4d06324 (patch) | |
tree | d4b82b3431a90e48895fceb83a34533a047fa035 /src/corelib/kernel/qvariant.cpp | |
parent | 7deb49d886a317ed993d82485cdb2723d367dce6 (diff) |
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>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 8f413b52e0..19fb33b675 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -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() */ |