QMetaType 過時成員

以下成員源於類 QMetaType 被棄用。 提供它們是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它們。

靜態公共成員

(棄用) bool compare (const void * lhs , const void * rhs , int typeId , int * result )
(棄用) void * construct (int type , void * where , const void * copy )
(棄用) bool convert (const void * from , int fromTypeId , void * to , int toTypeId )
(棄用) void * create (int type , const void * copy = nullptr)
(棄用) bool debugStream (QDebug & dbg , const void * rhs , int typeId )
(棄用) void destroy (int type , void * data )
(棄用) void destruct (int type , void * where )
(棄用) bool hasRegisteredDebugStreamOperator ()
(棄用) bool hasRegisteredDebugStreamOperator (int typeId )
(棄用) bool load (QDataStream & stream , int type , void * data )
(棄用) const QMetaObject * metaObjectForType (int type )
(棄用) bool save (QDataStream & stream , int type , const void * data )
(棄用) int sizeOf (int type )
(棄用) int type (const char * typeName )
(棄用) int type (const QByteArray & typeName )
(棄用) QMetaType::TypeFlags typeFlags (int type )
(棄用) const char * typeName (int typeId )

相關非成員

(棄用) int qRegisterMetaType (const char * typeName )

成員函數文檔編製

[static, deprecated] bool QMetaType:: compare (const void * lhs , const void * rhs , int typeId , int * result )

This function is deprecated. We strongly advise against using it in new code.

Use the non-static compare method instead

比較對象在 lhs and rhs . Both objects need to be of type typeId . result is set to less than, equal to or greater than zero, if lhs is less than, equal to or greater than rhs 。返迴 true , if the comparison succeeded, otherwise false .

[static, deprecated] void *QMetaType:: construct ( int type , void * where , const void * copy )

This function is deprecated. We strongly advise against using it in new code.

Constructs a value of the given type in the existing memory addressed by where , that is a copy of copy ,並返迴 where 。若 copy is zero, the value is default constructed.

This is a low-level function for explicitly managing the memory used to store the type. Consider calling create () if you don't need this level of control (that is, use "new" rather than "placement new").

You must ensure that where points to a location that can store a value of type type , and that where is suitably aligned. The type's size can be queried by calling sizeOf ().

The rule of thumb for alignment is that a type is aligned to its natural boundary, which is the smallest power of 2 that is bigger than the type, unless that alignment is larger than the maximum useful alignment for the platform. For practical purposes, alignment larger than 2 * sizeof(void*) is only necessary for special hardware instructions (e.g., aligned SSE loads and stores on x86).

另請參閱 destruct () 和 sizeOf ().

[static, deprecated] bool QMetaType:: convert (const void * from , int fromTypeId , void * to , int toTypeId )

This function is deprecated. We strongly advise against using it in new code.

Converts the object at from from fromTypeId to the preallocated space at to typed toTypeId 。返迴 true ,若轉換成功,否則 false。

Both from and to have to be valid pointers.

[static, deprecated] void *QMetaType:: create ( int type , const void * copy = nullptr)

This function is deprecated. We strongly advise against using it in new code.

Returns a copy of copy , assuming it is of type type 。若 copy is zero, creates a default constructed instance.

另請參閱 destroy (), isRegistered (),和 Type .

[static, deprecated] bool QMetaType:: debugStream ( QDebug & dbg , const void * rhs , int typeId )

This function is deprecated. We strongly advise against using it in new code.

這是重載函數。

[static, deprecated] void QMetaType:: destroy ( int type , void * data )

This function is deprecated. We strongly advise against using it in new code.

銷毀 data , assuming it is of the type 給定。

另請參閱 create (), isRegistered (),和 Type .

[static, deprecated] void QMetaType:: destruct ( int type , void * where )

This function is deprecated. We strongly advise against using it in new code.

Destructs the value of the given type , located at where .

不像 destroy (), this function only invokes the type's destructor, it doesn't invoke the delete operator.

另請參閱 construct ().

[static, deprecated] template <typename T> bool QMetaType:: hasRegisteredDebugStreamOperator ()

This function is deprecated. We strongly advise against using it in new code.

返迴 true , if the meta type system has a registered debug stream operator for type T.

[static, deprecated] bool QMetaType:: hasRegisteredDebugStreamOperator ( int typeId )

This function is deprecated. We strongly advise against using it in new code.

使用 QMetaType::hasRegisteredDebugStreamOperator () 代替。

返迴 true , if the meta type system has a registered debug stream operator for type id typeId .

[static, deprecated] bool QMetaType:: load ( QDataStream & stream , int type , void * data )

This function is deprecated. We strongly advise against using it in new code.

這是重載函數。

[static, deprecated] const QMetaObject *QMetaType:: metaObjectForType ( int type )

This function is deprecated. We strongly advise against using it in new code.

返迴 QMetaType::metaObject for type

另請參閱 metaObject ().

[static, deprecated] bool QMetaType:: save ( QDataStream & stream , int type , const void * data )

This function is deprecated. We strongly advise against using it in new code.

這是重載函數。

[static, deprecated] int QMetaType:: sizeOf ( int type )

This function is deprecated. We strongly advise against using it in new code.

Returns the size of the given type in bytes (i.e. sizeof(T), where T is the actual type identified by the type argument).

This function is typically used together with construct () to perform low-level management of the memory used by a type.

另請參閱 construct () 和 QMetaType::alignOf ().

[static, deprecated] int QMetaType:: type (const char * typeName )

This function is deprecated. We strongly advise against using it in new code.

將句柄返迴給類型調用 typeName ,或 QMetaType::UnknownType 若沒有這種類型。

另請參閱 isRegistered (), typeName (),和 Type .

[static, deprecated] int QMetaType:: type (const QByteArray & typeName )

This function is deprecated. We strongly advise against using it in new code.

這是重載函數。

將句柄返迴給類型調用 typeName ,或 0 若沒有這種類型。

另請參閱 isRegistered () 和 typeName ().

[static, deprecated] QMetaType::TypeFlags QMetaType:: typeFlags ( int type )

This function is deprecated. We strongly advise against using it in new code.

返迴標誌為給定 type .

另請參閱 QMetaType::TypeFlags .

[static, deprecated] const char *QMetaType:: typeName ( int typeId )

This function is deprecated. We strongly advise against using it in new code.

Returns the type name associated with the given typeId , or a null pointer if no matching type was found. The returned pointer must not be deleted.

另請參閱 type (), isRegistered (), Type ,和 name ().

相關非成員

[deprecated] template <typename T> int qRegisterMetaType (const char * typeName )

This function is deprecated. We strongly advise against using it in new code.

注冊類型名稱 typeName 為類型 T 。返迴的內部 ID 用於 QMetaType 。可以注冊擁有公共默認構造函數、公共副本構造函數和公共析構函數的任何類 (或結構)。

此函數要求 T 是在函數被調用時的完全定義類型。對於指針類型,它還要求指嚮完全定義的類型。使用 Q_DECLARE_OPAQUE_POINTER () 能夠注冊指嚮轉發聲明類型的指針。

在已注冊類型後,可以在運行時動態創建和銷毀該類型的對象。

此範例注冊類 MyClass :

qRegisterMetaType<MyClass>("MyClass");
					

此函數對注冊 typedef 很有用,因此它們可以用於 QMetaProperty ,或在 QueuedConnections

typedef QString CustomString;
qRegisterMetaType<CustomString>("CustomString");
					

警告: 此函數僅適用於注冊彆名 (typedef) 為每種其它用例 Q_DECLARE_METATYPE and qMetaTypeId () 應該被使用以取而代之。

另請參閱 isRegistered () 和 Q_DECLARE_METATYPE ().