以下成员源于类 QVariant 被弃用。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。
(弃用)
enum
|
Type { Invalid, BitArray, Bitmap, Bool, Brush, …, UserType } |
(deprecated (6.0))
|
QVariant (QVariant::Type type ) |
(deprecated (6.0))
bool
|
canConvert (int targetTypeId ) const |
(deprecated (6.0))
bool
|
convert (int targetTypeId ) |
(deprecated (6.0))
QVariant::Type
|
type () const |
(deprecated (6.0))
QVariant::Type
|
nameToType (const char * name ) |
(deprecated (6.0))
const char *
|
typeToName (int typeId ) |
(deprecated (6.0))
QDataStream &
|
operator<< (QDataStream & s , const QVariant::Type p ) |
(deprecated (6.0))
QDataStream &
|
operator>> (QDataStream & s , QVariant::Type & p ) |
This enum is deprecated. We strongly advise against using it in new code.
使用 QMetaType::Type 代替。
This enum type defines the types of variable that a QVariant can contain.
常量 | 值 | 描述 |
---|---|---|
QVariant::Invalid
|
QMetaType::UnknownType
|
no type |
QVariant::BitArray
|
QMetaType::QBitArray
|
a QBitArray |
QVariant::Bitmap
|
QMetaType::QBitmap
|
a QBitmap |
QVariant::Bool
|
QMetaType::Bool
|
a bool |
QVariant::Brush
|
QMetaType::QBrush
|
a QBrush |
QVariant::ByteArray
|
QMetaType::QByteArray
|
a QByteArray |
QVariant::Char
|
QMetaType::QChar
|
a QChar |
QVariant::Color
|
QMetaType::QColor
|
a QColor |
QVariant::Cursor
|
QMetaType::QCursor
|
a QCursor |
QVariant::Date
|
QMetaType::QDate
|
a QDate |
QVariant::DateTime
|
QMetaType::QDateTime
|
a QDateTime |
QVariant::Double
|
QMetaType::Double
|
a double |
QVariant::EasingCurve
|
QMetaType::QEasingCurve
|
a QEasingCurve |
QVariant::Uuid
|
QMetaType::QUuid
|
a QUuid |
QVariant::ModelIndex
|
QMetaType::QModelIndex
|
a QModelIndex |
QVariant::PersistentModelIndex (since Qt 5.5)
|
QMetaType::QPersistentModelIndex
|
a QPersistentModelIndex |
QVariant::Font
|
QMetaType::QFont
|
a QFont |
QVariant::Hash
|
QMetaType::QVariantHash
|
a QVariantHash |
QVariant::Icon
|
QMetaType::QIcon
|
a QIcon |
QVariant::Image
|
QMetaType::QImage
|
a QImage |
QVariant::Int
|
QMetaType::Int
|
an int |
QVariant::KeySequence
|
QMetaType::QKeySequence
|
a QKeySequence |
QVariant::Line
|
QMetaType::QLine
|
a QLine |
QVariant::LineF
|
QMetaType::QLineF
|
a QLineF |
QVariant::List
|
QMetaType::QVariantList
|
a QVariantList |
QVariant::Locale
|
QMetaType::QLocale
|
a QLocale |
QVariant::LongLong
|
QMetaType::LongLong
|
a qlonglong |
QVariant::Map
|
QMetaType::QVariantMap
|
a QVariantMap |
QVariant::Transform
|
QMetaType::QTransform
|
a QTransform |
QVariant::Matrix4x4
|
QMetaType::QMatrix4x4
|
a QMatrix4x4 |
QVariant::Palette
|
QMetaType::QPalette
|
a QPalette |
QVariant::Pen
|
QMetaType::QPen
|
a QPen |
QVariant::Pixmap
|
QMetaType::QPixmap
|
a QPixmap |
QVariant::Point
|
QMetaType::QPoint
|
a QPoint |
QVariant::PointF
|
QMetaType::QPointF
|
a QPointF |
QVariant::Polygon
|
QMetaType::QPolygon
|
a QPolygon |
QVariant::PolygonF
|
QMetaType::QPolygonF
|
a QPolygonF |
QVariant::Quaternion
|
QMetaType::QQuaternion
|
a QQuaternion |
QVariant::Rect
|
QMetaType::QRect
|
a QRect |
QVariant::RectF
|
QMetaType::QRectF
|
a QRectF |
QVariant::RegularExpression
|
QMetaType::QRegularExpression
|
a QRegularExpression |
QVariant::Region
|
QMetaType::QRegion
|
a QRegion |
QVariant::Size
|
QMetaType::QSize
|
a QSize |
QVariant::SizeF
|
QMetaType::QSizeF
|
a QSizeF |
QVariant::SizePolicy
|
QMetaType::QSizePolicy
|
a QSizePolicy |
QVariant::String
|
QMetaType::QString
|
a QString |
QVariant::StringList
|
QMetaType::QStringList
|
a QStringList |
QVariant::TextFormat
|
QMetaType::QTextFormat
|
a QTextFormat |
QVariant::TextLength
|
QMetaType::QTextLength
|
a QTextLength |
QVariant::Time
|
QMetaType::QTime
|
a QTime |
QVariant::UInt
|
QMetaType::UInt
|
a uint |
QVariant::ULongLong
|
QMetaType::ULongLong
|
a qulonglong |
QVariant::Url
|
QMetaType::QUrl
|
a QUrl |
QVariant::Vector2D
|
QMetaType::QVector2D
|
a QVector2D |
QVariant::Vector3D
|
QMetaType::QVector3D
|
a QVector3D |
QVariant::Vector4D
|
QMetaType::QVector4D
|
a QVector4D |
QVariant::UserType
|
QMetaType::User
|
Base value for user-defined types. |
[explicit]
QVariant::
QVariant
(
QVariant::Type
type
)
This function is deprecated since 6.0. We strongly advise against using it in new code.
Use the constructor taking a QMetaType 代替。
Constructs an uninitialized variant of type type . This will create a variant in a special null state that if accessed will return a default constructed value of the type .
另请参阅 isNull ().
This function is deprecated since 6.0. We strongly advise against using it in new code.
这是重载函数。
使用
canConvert(QMetaType(targetTypeId))
代替。
另请参阅 QMetaType::canConvert ().
This function is deprecated since 6.0. We strongly advise against using it in new code.
使用
convert(QMetaType(targetTypeId))
代替。
将变体铸造成请求类型, targetTypeId . If the cast cannot be done, the variant is still changed to the requested type, but is left in a cleared null state similar to that constructed by QVariant (Type).
返回
true
if the current type of the variant was successfully cast; otherwise returns
false
.
A QVariant containing a pointer to a type derived from QObject will also convert and return true for this function if a qobject_cast to the type described by targetTypeId would succeed. Note that this only works for QObject subclasses which use the Q_OBJECT 宏。
注意:
converting QVariants that are null due to not being initialized or having failed a previous conversion will always fail, changing the type, remaining null, and returning
false
.
另请参阅 canConvert () 和 clear ().
[static]
QVariant::Type
QVariant::
nameToType
(const
char
*
name
)
This function is deprecated since 6.0. We strongly advise against using it in new code.
使用
QMetaType::fromName(name).id()
代替
Converts the string representation of the storage type given in name , to its enum representation.
If the string representation cannot be converted to any enum representation, the variant is set to
Invalid
.
This function is deprecated since 6.0. We strongly advise against using it in new code.
使用 typeId () 或 metaType () 代替。
Returns the storage type of the value stored in the variant. Although this function is declared as returning QVariant::Type , the return value should be interpreted as QMetaType::Type . In particular, QVariant::UserType is returned here only if the value is equal or greater than QMetaType::User .
Note that return values in the ranges QVariant::Char through QVariant::RegExp and QVariant::Font through QVariant::Transform correspond to the values in the ranges QMetaType::QChar through QMetaType::QRegularExpression and QMetaType::QFont through QMetaType::QQuaternion .
Pay particular attention when working with char and
QChar
variants. Note that there is no
QVariant
constructor specifically for type char, but there is one for
QChar
. For a variant of type
QChar
,此函数返回
QVariant::Char
, which is the same as
QMetaType::QChar
, but for a variant of type
char
,此函数返回
QMetaType::Char
,其是
not
the same as
QVariant::Char
.
Also note that the types
void*
,
long
,
short
,
unsigned
long
,
unsigned
short
,
unsigned
char
,
float
,
QObject*
,和
QWidget*
are represented in
QMetaType::Type
but not in
QVariant::Type
, and they can be returned by this function. However, they are considered to be user defined types when tested against
QVariant::Type
.
To test whether an instance of QVariant contains a data type that is compatible with the data type you are interested in, use canConvert ().
另请参阅 userType () 和 metaType ().
[static]
const
char
*QVariant::
typeToName
(
int
typeId
)
This function is deprecated since 6.0. We strongly advise against using it in new code.
使用
QMetaType(typeId).name()
代替。
Converts the int representation of the storage type, typeId , to its string representation.
返回
nullptr
if the type is
QMetaType::UnknownType
or doesn't exist.
This function is deprecated since 6.0. We strongly advise against using it in new code.
Stream QMetaType::Type 代替。
Writes a variant type p 到流 s .
This function is deprecated since 6.0. We strongly advise against using it in new code.
Stream QMetaType::Type 代替。
Reads a variant type p in enum representation from the stream s .