Obsolete Members for QVariant

クラスQVariant の以下のメンバーは非推奨です。これらは古いソース・コードの動作を維持するために提供されています。新しいコードでは使用しないことを強くお勧めします。

パブリック型

(deprecated) enum Type { Invalid, BitArray, Bitmap, Bool, Brush, …, UserType }

パブリック関数

(deprecated in 6.0) QVariant(QVariant::Type type)
(deprecated in 6.0) bool canConvert(int targetTypeId) const
(deprecated in 6.0) bool convert(int targetTypeId)
(deprecated in 6.0) QVariant::Type type() const

静的パブリック・メンバ

(deprecated in 6.0) QVariant::Type nameToType(const char *name)
(deprecated in 6.0) const char *typeToName(int typeId)

関連する非メンバー

(deprecated in 6.0) QDataStream &operator<<(QDataStream &s, const QVariant::Type p)
(deprecated in 6.0) QDataStream &operator>>(QDataStream &s, QVariant::Type &p)

メンバー型ドキュメント

[deprecated] enum QVariant::Type

この列挙型は非推奨である。新しいコードでは使用しないことを強くお勧めします。

代わりにQMetaType::Type

この列挙型は、QVariant が含むことができる変数の型を定義します。

定数説明
QVariant::InvalidQMetaType::UnknownType型なし
QVariant::BitArrayQMetaType::QBitArrayaQBitArray
QVariant::BitmapQMetaType::QBitmapaQBitmap
QVariant::BoolQMetaType::Boolブール
QVariant::BrushQMetaType::QBrushaQBrush
QVariant::ByteArrayQMetaType::QByteArrayaQByteArray
QVariant::CharQMetaType::QCharaQChar
QVariant::ColorQMetaType::QColoraQColor
QVariant::CursorQMetaType::QCursoraQCursor
QVariant::DateQMetaType::QDateaQDate
QVariant::DateTimeQMetaType::QDateTimeaQDateTime
QVariant::DoubleQMetaType::Double
QVariant::EasingCurveQMetaType::QEasingCurveaQEasingCurve
QVariant::UuidQMetaType::QUuidaQUuid
QVariant::ModelIndexQMetaType::QModelIndexaQModelIndex
QVariant::PersistentModelIndex (since Qt 5.5)QMetaType::QPersistentModelIndexaQPersistentModelIndex
QVariant::FontQMetaType::QFontaQFont
QVariant::HashQMetaType::QVariantHashaQVariantHash
QVariant::IconQMetaType::QIconaQIcon
QVariant::ImageQMetaType::QImageaQImage
QVariant::IntQMetaType::Intan int
QVariant::KeySequenceQMetaType::QKeySequenceaQKeySequence
QVariant::LineQMetaType::QLineaQLine
QVariant::LineFQMetaType::QLineFaQLineF
QVariant::ListQMetaType::QVariantListaQVariantList
QVariant::LocaleQMetaType::QLocaleaQLocale
QVariant::LongLongQMetaType::LongLongaqlonglong
QVariant::MapQMetaType::QVariantMapaQVariantMap
QVariant::TransformQMetaType::QTransformaQTransform
QVariant::Matrix4x4QMetaType::QMatrix4x4aQMatrix4x4
QVariant::PaletteQMetaType::QPaletteaQPalette
QVariant::PenQMetaType::QPenaQPen
QVariant::PixmapQMetaType::QPixmapaQPixmap
QVariant::PointQMetaType::QPointaQPoint
QVariant::PointFQMetaType::QPointFaQPointF
QVariant::PolygonQMetaType::QPolygonaQPolygon
QVariant::PolygonFQMetaType::QPolygonFaQPolygonF
QVariant::QuaternionQMetaType::QQuaternionaQQuaternion
QVariant::RectQMetaType::QRectaQRect
QVariant::RectFQMetaType::QRectFaQRectF
QVariant::RegularExpressionQMetaType::QRegularExpressionaQRegularExpression
QVariant::RegionQMetaType::QRegionaQRegion
QVariant::SizeQMetaType::QSizeaQSize
QVariant::SizeFQMetaType::QSizeFaQSizeF
QVariant::SizePolicyQMetaType::QSizePolicyaQSizePolicy
QVariant::StringQMetaType::QStringaQString
QVariant::StringListQMetaType::QStringListaQStringList
QVariant::TextFormatQMetaType::QTextFormataQTextFormat
QVariant::TextLengthQMetaType::QTextLengthaQTextLength
QVariant::TimeQMetaType::QTimeaQTime
QVariant::UIntQMetaType::UIntauint
QVariant::ULongLongQMetaType::ULongLongaqulonglong
QVariant::UrlQMetaType::QUrlaQUrl
QVariant::Vector2DQMetaType::QVector2DaQVector2D
QVariant::Vector3DQMetaType::QVector3DaQVector3D
QVariant::Vector4DQMetaType::QVector4DaQVector4D
QVariant::UserTypeQMetaType::Userユーザー定義型の基本値。

メンバ関数ドキュメント

[explicit, deprecated in 6.0] QVariant::QVariant(QVariant::Type type)

この関数は6.0から非推奨となった。新しいコードでは使わないことを強くお勧めします。

代わりにQMetaType を取るコンストラクタを使用してください。

type 型の初期化されていないバリアントを構築します。これは特別な null 状態のバリアントを作成し、アクセスされた場合はtype のデフォルト値を返します。

isNull()も参照してください

[deprecated in 6.0] bool QVariant::canConvert(int targetTypeId) const

この関数は6.0から非推奨となった。新しいコードでは使用しないことを強くお勧めします。

これはオーバーロードされた関数です。

代わりにcanConvert(QMetaType(targetTypeId)) を使用してください。

QMetaType::canConvert()も参照

[deprecated in 6.0] bool QVariant::convert(int targetTypeId)

この関数は6.0から非推奨となった。新しいコードでは使用しないことを強くお勧めします。

代わりにconvert(QMetaType(targetTypeId)) を使ってください。

要求された型に variant をキャストします。targetTypeId 。キャストができなかった場合、バリアントは要求された型に変更されますが、QVariant(Type) で構築されたのと同じようなクリアされた null 状態になります。

バリアントの現在の型が正常にキャストされた場合はtrue を返し、そうでない場合はfalse を返します。

QObject から派生した型へのポインタを含むQVariant も、targetTypeId で記述された型へのqobject_cast が成功する場合は変換され、この関数に対して真を返します。これはQ_OBJECT マクロを使用するQObject サブクラスに対してのみ機能することに注意してください。

注意: 初期化されていなかったり、以前の変換に失敗したために NULL となっている QVariants の変換は常に失敗し、型が変更され、NULL のままとなり、false を返します。

canConvert() およびclear()も参照してください

[static, deprecated in 6.0] QVariant::Type QVariant::nameToType(const char *name)

この関数は6.0から非推奨となった。新しいコードでは使用しないことを強くお勧めします。

代わりにQMetaType::fromName(name).id() を使用してください。

name で与えられたストレージ型の文字列表現を列挙型表現に変換します。

文字列表現がどの列挙型表現にも変換できない場合、バリアントはInvalid に設定されます。

[deprecated in 6.0] QVariant::Type QVariant::type() const

この関数は6.0から非推奨となった。新しいコードでは使用しないことを強く推奨する。

代わりにtypeId() かmetaType() を使ってください。

バリアントに格納されている値の格納タイプを返します。この関数はQVariant::Type を返すと宣言されていますが、返り値はQMetaType::Type と解釈されるべきです。特に、QVariant::UserType は、値がQMetaType::User と等しいか大きい場合にのみ返されます。

QVariant::Char ~ QVariant::RegExp およびQVariant::FontQVariant::Transform の範囲の戻り値は、QMetaType::QCharQMetaType::QRegularExpression およびQMetaType::QFontQMetaType::QQuaternion の範囲の値に対応することに注意してください。

charとQChar のバリアントを扱うときは特に注意してください。char型専用のコンストラクタはQVariant にはありませんが、QChar にはあることに注意してください。QChar 型のバリアントの場合、この関数はQMetaType::QChar と同じQVariant::Char を返しますが、char 型のバリアントの場合、この関数はQVariant::Char とは異なる QMetaType::Char を返します。

また、型void*longshortunsignedlongunsignedshortunsignedcharfloatQObject*QWidget* は、QMetaType::Type では表現されているが、QVariant::Type では表現されておらず、この関数で返すことができることに注意。しかし、QVariant::Type に対してテストする場合、これらはユーザー定義型とみなされる。

QVariant のインスタンスに、目的のデータ型と互換性のあるデータ型が含まれているかどうかをテストするには、canConvert() を使用する。

userType() およびmetaType()も参照のこと

[static, deprecated in 6.0] const char *QVariant::typeToName(int typeId)

この関数は6.0から非推奨となった。新しいコードでは使用しないことを強くお勧めします。

代わりにQMetaType(typeId).name() を使用してください。

格納型typeId の int 表現を文字列表現に変換します。

型がQMetaType::UnknownType であるか、存在しない場合はnullptr を返します。

関連する非会員

[deprecated in 6.0] QDataStream &operator<<(QDataStream &s, const QVariant::Type p)

この関数は6.0から非推奨となった。新しいコードでは使用しないことを強くお勧めします。

代わりにストリームQMetaType::Type

バリアント型p をストリームs に書き込みます。

[deprecated in 6.0] QDataStream &operator>>(QDataStream &s, QVariant::Type &p)

この関数は6.0から非推奨となった。新しいコードでは使用しないことを強くお勧めします。

代わりにストリームQMetaType::Type

ストリームs から、enum 表現のバリアント型p を読み込みます。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.