📄 qmetatype.cpp
字号:
return new short(*static_cast<const short*>(copy)); case QMetaType::Char: return new char(*static_cast<const char*>(copy)); case QMetaType::ULong: return new ulong(*static_cast<const ulong*>(copy)); case QMetaType::UInt: return new uint(*static_cast<const uint*>(copy)); case QMetaType::LongLong: return new qlonglong(*static_cast<const qlonglong*>(copy)); case QMetaType::ULongLong: return new qulonglong(*static_cast<const qulonglong*>(copy)); case QMetaType::UShort: return new ushort(*static_cast<const ushort*>(copy)); case QMetaType::UChar: return new uchar(*static_cast<const uchar*>(copy)); case QMetaType::Bool: return new bool(*static_cast<const bool*>(copy)); case QMetaType::Float: return new float(*static_cast<const float*>(copy)); case QMetaType::Double: return new double(*static_cast<const double*>(copy)); case QMetaType::QChar: return new ::QChar(*static_cast<const ::QChar*>(copy));#ifndef QT_BOOTSTRAPPED case QMetaType::QVariantMap: return new ::QVariantMap(*static_cast<const ::QVariantMap*>(copy)); case QMetaType::QVariantList: return new ::QVariantList(*static_cast<const ::QVariantList*>(copy));#endif case QMetaType::QByteArray: return new ::QByteArray(*static_cast<const ::QByteArray*>(copy)); case QMetaType::QString: return new ::QString(*static_cast<const ::QString*>(copy)); case QMetaType::QStringList: return new ::QStringList(*static_cast<const ::QStringList *>(copy));#ifndef QT_BOOTSTRAPPED case QMetaType::QBitArray: return new ::QBitArray(*static_cast<const ::QBitArray *>(copy));#endif case QMetaType::QDate: return new ::QDate(*static_cast<const ::QDate *>(copy)); case QMetaType::QTime: return new ::QTime(*static_cast<const ::QTime *>(copy)); case QMetaType::QDateTime: return new ::QDateTime(*static_cast<const ::QDateTime *>(copy));#ifndef QT_BOOTSTRAPPED case QMetaType::QUrl: return new ::QUrl(*static_cast<const ::QUrl *>(copy));#endif case QMetaType::QLocale: return new ::QLocale(*static_cast<const ::QLocale *>(copy));#ifndef QT_NO_GEOM_VARIANT case QMetaType::QRect: return new ::QRect(*static_cast<const ::QRect *>(copy)); case QMetaType::QRectF: return new ::QRectF(*static_cast<const ::QRectF *>(copy)); case QMetaType::QSize: return new ::QSize(*static_cast<const ::QSize *>(copy)); case QMetaType::QSizeF: return new ::QSizeF(*static_cast<const ::QSizeF *>(copy)); case QMetaType::QLine: return new ::QLine(*static_cast<const ::QLine *>(copy)); case QMetaType::QLineF: return new ::QLineF(*static_cast<const ::QLineF *>(copy)); case QMetaType::QPoint: return new ::QPoint(*static_cast<const ::QPoint *>(copy)); case QMetaType::QPointF: return new ::QPointF(*static_cast<const ::QPointF *>(copy));#endif#ifndef QT_NO_REGEXP case QMetaType::QRegExp: return new ::QRegExp(*static_cast<const ::QRegExp *>(copy));#endif case QMetaType::Void: return 0; default: ; } } else { switch(type) { case QMetaType::VoidStar: case QMetaType::QObjectStar: case QMetaType::QWidgetStar: return new void *; case QMetaType::Long: return new long; case QMetaType::Int: return new int; case QMetaType::Short: return new short; case QMetaType::Char: return new char; case QMetaType::ULong: return new ulong; case QMetaType::UInt: return new uint; case QMetaType::LongLong: return new qlonglong; case QMetaType::ULongLong: return new qulonglong; case QMetaType::UShort: return new ushort; case QMetaType::UChar: return new uchar; case QMetaType::Bool: return new bool; case QMetaType::Float: return new float; case QMetaType::Double: return new double; case QMetaType::QChar: return new ::QChar;#ifndef QT_BOOTSTRAPPED case QMetaType::QVariantMap: return new ::QVariantMap; case QMetaType::QVariantList: return new ::QVariantList;#endif case QMetaType::QByteArray: return new ::QByteArray; case QMetaType::QString: return new ::QString; case QMetaType::QStringList: return new ::QStringList;#ifndef QT_BOOTSTRAPPED case QMetaType::QBitArray: return new ::QBitArray;#endif case QMetaType::QDate: return new ::QDate; case QMetaType::QTime: return new ::QTime; case QMetaType::QDateTime: return new ::QDateTime;#ifndef QT_BOOTSTRAPPED case QMetaType::QUrl: return new ::QUrl;#endif case QMetaType::QLocale: return new ::QLocale;#ifndef QT_NO_GEOM_VARIANT case QMetaType::QRect: return new ::QRect; case QMetaType::QRectF: return new ::QRectF; case QMetaType::QSize: return new ::QSize; case QMetaType::QSizeF: return new ::QSizeF; case QMetaType::QLine: return new ::QLine; case QMetaType::QLineF: return new ::QLineF; case QMetaType::QPoint: return new ::QPoint; case QMetaType::QPointF: return new ::QPointF;#endif#ifndef QT_NO_REGEXP case QMetaType::QRegExp: return new ::QRegExp;#endif case QMetaType::Void: return 0; default: ; } } Constructor constr = 0; if (type >= FirstGuiType && type <= LastGuiType) { if (!qMetaTypeGuiHelper) return 0; constr = qMetaTypeGuiHelper[type - FirstGuiType].constr; } else { const QVector<QCustomTypeInfo> * const ct = customTypes(); QReadLocker locker(customTypesLock()); if (type < User || !ct || ct->count() <= type - User) return 0; constr = ct->at(type - User).constr; } return constr(copy);}/*! Destroys the \a data, assuming it is of the \a type given. \sa construct(), isRegistered(), Type*/void QMetaType::destroy(int type, void *data){ if (!data) return; switch(type) { case QMetaType::VoidStar: case QMetaType::QObjectStar: case QMetaType::QWidgetStar: delete static_cast<void**>(data); break; case QMetaType::Long: delete static_cast<long*>(data); break; case QMetaType::Int: delete static_cast<int*>(data); break; case QMetaType::Short: delete static_cast<short*>(data); break; case QMetaType::Char: delete static_cast<char*>(data); break; case QMetaType::ULong: delete static_cast<ulong*>(data); break; case QMetaType::LongLong: delete static_cast<qlonglong*>(data); break; case QMetaType::ULongLong: delete static_cast<qulonglong*>(data); break; case QMetaType::UInt: delete static_cast<uint*>(data); break; case QMetaType::UShort: delete static_cast<ushort*>(data); break; case QMetaType::UChar: delete static_cast<uchar*>(data); break; case QMetaType::Bool: delete static_cast<bool*>(data); break; case QMetaType::Float: delete static_cast<float*>(data); break; case QMetaType::Double: delete static_cast<double*>(data); break; case QMetaType::QChar: delete static_cast< ::QChar*>(data); break;#ifndef QT_BOOTSTRAPPED case QMetaType::QVariantMap: delete static_cast< ::QVariantMap*>(data); break; case QMetaType::QVariantList: delete static_cast< ::QVariantList*>(data); break;#endif case QMetaType::QByteArray: delete static_cast< ::QByteArray*>(data); break; case QMetaType::QString: delete static_cast< ::QString*>(data); break; case QMetaType::QStringList: delete static_cast< ::QStringList*>(data); break;#ifndef QT_BOOTSTRAPPED case QMetaType::QBitArray: delete static_cast< ::QBitArray*>(data); break;#endif case QMetaType::QDate: delete static_cast< ::QDate*>(data); break; case QMetaType::QTime: delete static_cast< ::QTime*>(data); break; case QMetaType::QDateTime: delete static_cast< ::QDateTime*>(data); break;#ifndef QT_BOOTSTRAPPED case QMetaType::QUrl: delete static_cast< ::QUrl*>(data);#endif break; case QMetaType::QLocale: delete static_cast< ::QLocale*>(data); break;#ifndef QT_NO_GEOM_VARIANT case QMetaType::QRect: delete static_cast< ::QRect*>(data); break; case QMetaType::QRectF: delete static_cast< ::QRectF*>(data); break; case QMetaType::QSize: delete static_cast< ::QSize*>(data); break; case QMetaType::QSizeF: delete static_cast< ::QSizeF*>(data); break; case QMetaType::QLine: delete static_cast< ::QLine*>(data); break; case QMetaType::QLineF: delete static_cast< ::QLineF*>(data); break; case QMetaType::QPoint: delete static_cast< ::QPoint*>(data); break; case QMetaType::QPointF: delete static_cast< ::QPointF*>(data); break;#endif#ifndef QT_NO_REGEXP case QMetaType::QRegExp: delete static_cast< ::QRegExp*>(data); break;#endif case QMetaType::Void: break; default: { const QVector<QCustomTypeInfo> * const ct = customTypes(); Destructor destr = 0; if (type >= FirstGuiType && type <= LastGuiType) { Q_ASSERT(qMetaTypeGuiHelper); if (!qMetaTypeGuiHelper) return; destr = qMetaTypeGuiHelper[type - FirstGuiType].destr; } else { QReadLocker locker(customTypesLock()); if (type < User || !ct || ct->count() <= type - User) break; destr = ct->at(type - User).destr; } destr(data); break; } }}/*! \fn int qRegisterMetaType(const char *typeName) \relates QMetaType \threadsafe Registers the type name \a typeName to the type \c{T}. Returns the internal ID used by QMetaType. Any class or struct that has a public constructor, a public copy constructor, and a public destructor can be registered. After a type has been registered, you can create and destroy objects of that type dynamically at run-time. This example registers the class \c{MyClass}: \code qRegisterMetaType<MyClass>("MyClass"); \endcode \sa qRegisterMetaTypeStreamOperators(), QMetaType::isRegistered(), Q_DECLARE_METATYPE()*//*! \fn int qRegisterMetaTypeStreamOperators(const char *typeName) \relates QMetaType \threadsafe Registers the stream operators for the type \c{T} called \a typeName. Afterward, the type can be streamed using QMetaType::load() and QMetaType::save(). These functions are used when streaming a QVariant. \code qRegisterMetaTypeStreamOperators<MyClass>("MyClass"); \endcode The stream operators should have the following signatures: \code QDataStream &operator<<(QDataStream &out, const MyClass &myObj); QDataStream &operator>>(QDataStream &in, MyClass &myObj); \endcode \sa qRegisterMetaType(), QMetaType::isRegistered(), Q_DECLARE_METATYPE()*//*! \typedef QMetaType::Destructor \internal*//*! \typedef QMetaType::Constructor \internal*//*! \typedef QMetaType::SaveOperator \internal*//*! \typedef QMetaType::LoadOperator \internal*//*! \fn int qRegisterMetaType() \relates QMetaType \threadsafe \since 4.2 Call this function to register the type \c T. \c T must be declared with Q_DECLARE_METATYPE(). Returns the meta type Id. Example: \code int id = qRegisterMetaType<MyStruct>(); \endcode \bold{Note:} To use the type \c T in QVariant, using Q_DECLARE_METATYPE() is sufficient. To use the type \c T in queued signal and slot connections, \c{qRegisterMetaType<T>()} must be called before the first connection is established. \sa Q_DECLARE_METATYPE() *//*! \fn int qMetaTypeId() \relates QMetaType \threadsafe \since 4.1 Returns the meta type id of type \c T at compile time. If the type was not declared with Q_DECLARE_METATYPE(), compilation will fail. Typical usage: \code int id = qMetaTypeId<QString>(); // id is now QMetaType::QString id = qMetaTypeId<MyStruct>(); // compile error if MyStruct not declared \endcode QMetaType::type() returns the same ID as qMetaTypeId(), but does a lookup at runtime based on the name of the type. QMetaType::type() is a bit slower, but compilation succeeds if a type is not registered. \sa Q_DECLARE_METATYPE(), QMetaType::type()*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -