Expose type id from QMetaType instance
There is not reason why it should be kept in secret. Not having public accessor forces a user code to keep a copy of the id. Visible for example in QML (QQmlValueType). Change-Id: If0de65fb8d91bcd50880c66b5f87c68f6d888dd3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
20a8a277ee
commit
dca3dd66b4
@ -376,6 +376,13 @@ struct DefinedTypesFilter {
|
|||||||
information about a type, false otherwise.
|
information about a type, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn int QMetaType::id() const
|
||||||
|
\since 5.13
|
||||||
|
|
||||||
|
Returns id type hold by this QMetatype instance.
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn bool QMetaType::sizeOf() const
|
\fn bool QMetaType::sizeOf() const
|
||||||
\since 5.0
|
\since 5.0
|
||||||
|
@ -570,6 +570,7 @@ public:
|
|||||||
|
|
||||||
inline bool isValid() const;
|
inline bool isValid() const;
|
||||||
inline bool isRegistered() const;
|
inline bool isRegistered() const;
|
||||||
|
inline int id() const;
|
||||||
inline int sizeOf() const;
|
inline int sizeOf() const;
|
||||||
inline TypeFlags flags() const;
|
inline TypeFlags flags() const;
|
||||||
inline const QMetaObject *metaObject() const;
|
inline const QMetaObject *metaObject() const;
|
||||||
@ -2221,6 +2222,11 @@ inline bool QMetaType::isRegistered() const
|
|||||||
return isValid();
|
return isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int QMetaType::id() const
|
||||||
|
{
|
||||||
|
return m_typeId;
|
||||||
|
}
|
||||||
|
|
||||||
inline void *QMetaType::create(const void *copy) const
|
inline void *QMetaType::create(const void *copy) const
|
||||||
{
|
{
|
||||||
// ### TODO Qt6 remove the extension
|
// ### TODO Qt6 remove the extension
|
||||||
|
@ -73,6 +73,7 @@ private slots:
|
|||||||
void defined();
|
void defined();
|
||||||
void threadSafety();
|
void threadSafety();
|
||||||
void namespaces();
|
void namespaces();
|
||||||
|
void id();
|
||||||
void qMetaTypeId();
|
void qMetaTypeId();
|
||||||
void properties();
|
void properties();
|
||||||
void normalizedTypes();
|
void normalizedTypes();
|
||||||
@ -475,6 +476,12 @@ void tst_QMetaType::namespaces()
|
|||||||
QCOMPARE(QMetaType::typeName(qungTfuId), "TestSpace::QungTfu");
|
QCOMPARE(QMetaType::typeName(qungTfuId), "TestSpace::QungTfu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMetaType::id()
|
||||||
|
{
|
||||||
|
QCOMPARE(QMetaType(QMetaType::QString).id(), QMetaType::QString);
|
||||||
|
QCOMPARE(QMetaType(::qMetaTypeId<TestSpace::Foo>()).id(), ::qMetaTypeId<TestSpace::Foo>());
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QMetaType::qMetaTypeId()
|
void tst_QMetaType::qMetaTypeId()
|
||||||
{
|
{
|
||||||
QCOMPARE(::qMetaTypeId<QString>(), int(QMetaType::QString));
|
QCOMPARE(::qMetaTypeId<QString>(), int(QMetaType::QString));
|
||||||
|
Loading…
Reference in New Issue
Block a user