Qt 4.8
|
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus typesystem. More...
#include <qdbusextratypes.h>
Public Functions | |
QDBusVariant () | |
Constructs a new D-Bus variant. More... | |
QDBusVariant (const QVariant &variant) | |
Constructs a new D-Bus variant from the given Qt variant. More... | |
void | setVariant (const QVariant &variant) |
Assigns the value of the given Qt variant to this D-Bus variant. More... | |
QVariant | variant () const |
Returns this D-Bus variant as a QVariant object. More... | |
Additional Inherited Members | |
Private Types inherited from QVariant | |
typedef Private | DataPtr |
enum | Type { Invalid = 0, Bool = 1, Int = 2, UInt = 3, LongLong = 4, ULongLong = 5, Double = 6, Char = 7, Map = 8, List = 9, String = 10, StringList = 11, ByteArray = 12, BitArray = 13, Date = 14, Time = 15, DateTime = 16, Url = 17, Locale = 18, Rect = 19, RectF = 20, Size = 21, SizeF = 22, Line = 23, LineF = 24, Point = 25, PointF = 26, RegExp = 27, Hash = 28, EasingCurve = 29, LastCoreType = EasingCurve, Font = 64, Pixmap = 65, Brush = 66, Color = 67, Palette = 68, Icon = 69, Image = 70, Polygon = 71, Region = 72, Bitmap = 73, Cursor = 74, SizePolicy = 75, KeySequence = 76, Pen = 77, TextLength = 78, TextFormat = 79, Matrix = 80, Transform = 81, Matrix4x4 = 82, Vector2D = 83, Vector3D = 84, Vector4D = 85, Quaternion = 86, LastGuiType = Quaternion, UserType = 127, LastType = 0xffffffff } |
This enum type defines the types of variable that a QVariant can contain. More... | |
Private Functions inherited from QVariant | |
bool | canConvert (Type t) const |
Returns true if the variant's type can be cast to the requested type, t. More... | |
template<typename T > | |
bool | canConvert () const |
Returns true if the variant can be converted to the template type T , otherwise false. More... | |
void | clear () |
Convert this variant to type Invalid and free up any resources used. More... | |
const void * | constData () const |
bool | convert (Type t) |
Casts the variant to the requested type, t. More... | |
void * | data () |
const void * | data () const |
DataPtr & | data_ptr () |
void | detach () |
bool | isDetached () const |
bool | isNull () const |
Returns true if this is a NULL variant, false otherwise. More... | |
bool | isValid () const |
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false. More... | |
void | load (QDataStream &ds) |
Internal function for loading a variant from stream s. More... | |
bool | operator!= (const QVariant &v) const |
Compares this QVariant with v and returns true if they are not equal; otherwise returns false. More... | |
QVariant & | operator= (const QVariant &other) |
Assigns the value of the variant variant to this variant. More... | |
bool | operator== (const QVariant &v) const |
Compares this QVariant with v and returns true if they are equal; otherwise returns false. More... | |
QVariant () | |
Constructs an invalid variant. More... | |
QVariant (Type type) | |
Constructs a null variant of type type. More... | |
QVariant (int typeOrUserType, const void *copy) | |
Constructs variant of type typeOrUserType, and initializes with copy if copy is not 0. More... | |
QVariant (int typeOrUserType, const void *copy, uint flags) | |
QVariant (const QVariant &other) | |
Constructs a copy of the variant, p, passed as the argument to this constructor. More... | |
QVariant (QDataStream &s) | |
Reads the variant from the data stream, s. More... | |
QVariant (int i) | |
Constructs a new variant with an integer value, val. More... | |
QVariant (uint ui) | |
Constructs a new variant with an unsigned integer value, val. More... | |
QVariant (qlonglong ll) | |
Constructs a new variant with a long long integer value, val. More... | |
QVariant (qulonglong ull) | |
Constructs a new variant with an unsigned long long integer value, val. More... | |
QVariant (bool b) | |
Constructs a new variant with a boolean value, val. More... | |
QVariant (double d) | |
Constructs a new variant with a floating point value, val. More... | |
QVariant (float f) | |
Constructs a new variant with a floating point value, val. More... | |
QT_ASCII_CAST_WARN_CONSTRUCTOR | QVariant (const char *str) |
Constructs a new variant with a string value of val. More... | |
QVariant (const QByteArray &bytearray) | |
Constructs a new variant with a bytearray value, val. More... | |
QVariant (const QBitArray &bitarray) | |
Constructs a new variant with a bitarray value, val. More... | |
QVariant (const QString &string) | |
Constructs a new variant with a string value, val. More... | |
QVariant (const QLatin1String &string) | |
Constructs a new variant with a string value, val. More... | |
QVariant (const QStringList &stringlist) | |
Constructs a new variant with a string list value, val. More... | |
QVariant (const QChar &qchar) | |
Constructs a new variant with a char value, c. More... | |
QVariant (const QDate &date) | |
Constructs a new variant with a date value, val. More... | |
QVariant (const QTime &time) | |
Constructs a new variant with a time value, val. More... | |
QVariant (const QDateTime &datetime) | |
Constructs a new variant with a date/time value, val. More... | |
QVariant (const QList< QVariant > &list) | |
Constructs a new variant with a list value, val. More... | |
QVariant (const QMap< QString, QVariant > &map) | |
Constructs a new variant with a map of QVariants, val. More... | |
QVariant (const QHash< QString, QVariant > &hash) | |
Constructs a new variant with a hash of QVariants, val. More... | |
QVariant (const QSize &size) | |
Constructs a new variant with a size value of val. More... | |
QVariant (const QSizeF &size) | |
Constructs a new variant with a size value of val. More... | |
QVariant (const QPoint &pt) | |
Constructs a new variant with a point value of val. More... | |
QVariant (const QPointF &pt) | |
Constructs a new variant with a point value of val. More... | |
QVariant (const QLine &line) | |
Constructs a new variant with a line value of val. More... | |
QVariant (const QLineF &line) | |
Constructs a new variant with a line value of val. More... | |
QVariant (const QRect &rect) | |
Constructs a new variant with a rect value of val. More... | |
QVariant (const QRectF &rect) | |
Constructs a new variant with a rect value of val. More... | |
QVariant (const QUrl &url) | |
Constructs a new variant with a url value of val. More... | |
QVariant (const QLocale &locale) | |
Constructs a new variant with a locale value, l. More... | |
QVariant (const QRegExp ®Exp) | |
Constructs a new variant with the regexp value regExp. More... | |
QVariant (const QEasingCurve &easing) | |
Constructs a new variant with an easing curve value, val. More... | |
QVariant (Qt::GlobalColor color) | |
Constructs a new variant of type QVariant::Color and initializes it with color. More... | |
void | save (QDataStream &ds) const |
Internal function for saving a variant to the stream s. More... | |
template<typename T > | |
void | setValue (const T &value) |
Stores a copy of value. More... | |
void | swap (QVariant &other) |
Swaps variant other with this variant. More... | |
QBitArray | toBitArray () const |
Returns the variant as a QBitArray if the variant has type() BitArray ; otherwise returns an empty bit array. More... | |
bool | toBool () const |
Returns the variant as a bool if the variant has type() Bool. More... | |
QByteArray | toByteArray () const |
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QString::fromAscii()); otherwise returns an empty byte array. More... | |
QChar | toChar () const |
Returns the variant as a QChar if the variant has type() Char , Int , or UInt ; otherwise returns an invalid QChar. More... | |
QDate | toDate () const |
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise returns an invalid date. More... | |
QDateTime | toDateTime () const |
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise returns an invalid date/time. More... | |
double | toDouble (bool *ok=0) const |
Returns the variant as a double if the variant has type() Double , QMetaType::Float , Bool , ByteArray , Int , LongLong , String , UInt , or ULongLong ; otherwise returns 0.0. More... | |
QEasingCurve | toEasingCurve () const |
Returns the variant as a QEasingCurve if the variant has type() EasingCurve ; otherwise returns a default easing curve. More... | |
float | toFloat (bool *ok=0) const |
Returns the variant as a float if the variant has type() Double , QMetaType::Float , Bool , ByteArray , Int , LongLong , String , UInt , or ULongLong ; otherwise returns 0.0. More... | |
QHash< QString, QVariant > | toHash () const |
Returns the variant as a QHash<QString, QVariant> if the variant has type() Hash ; otherwise returns an empty map. More... | |
int | toInt (bool *ok=0) const |
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char , Double , LongLong , String , UInt , or ULongLong ; otherwise returns 0. More... | |
QLine | toLine () const |
Returns the variant as a QLine if the variant has type() Line ; otherwise returns an invalid QLine. More... | |
QLineF | toLineF () const |
Returns the variant as a QLineF if the variant has type() LineF ; otherwise returns an invalid QLineF. More... | |
QList< QVariant > | toList () const |
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise returns an empty list. More... | |
QLocale | toLocale () const |
Returns the variant as a QLocale if the variant has type() Locale ; otherwise returns an invalid QLocale. More... | |
qlonglong | toLongLong (bool *ok=0) const |
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0. More... | |
QMap< QString, QVariant > | toMap () const |
Returns the variant as a QMap<QString, QVariant> if the variant has type() Map ; otherwise returns an empty map. More... | |
QPoint | toPoint () const |
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null QPoint. More... | |
QPointF | toPointF () const |
Returns the variant as a QPointF if the variant has type() Point or PointF ; otherwise returns a null QPointF. More... | |
qreal | toReal (bool *ok=0) const |
Returns the variant as a qreal if the variant has type() Double , QMetaType::Float , Bool , ByteArray , Int , LongLong , String , UInt , or ULongLong ; otherwise returns 0.0. More... | |
QRect | toRect () const |
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect. More... | |
QRectF | toRectF () const |
Returns the variant as a QRectF if the variant has type() Rect or RectF ; otherwise returns an invalid QRectF. More... | |
QRegExp | toRegExp () const |
Returns the variant as a QRegExp if the variant has type() RegExp ; otherwise returns an empty QRegExp. More... | |
QSize | toSize () const |
Returns the variant as a QSize if the variant has type() Size ; otherwise returns an invalid QSize. More... | |
QSizeF | toSizeF () const |
Returns the variant as a QSizeF if the variant has type() SizeF ; otherwise returns an invalid QSizeF. More... | |
QString | toString () const |
Returns the variant as a QString if the variant has type() String , Bool , ByteArray , Char , Date , DateTime , Double , Int , LongLong , StringList , Time , UInt , or ULongLong ; otherwise returns an empty string. More... | |
QStringList | toStringList () const |
Returns the variant as a QStringList if the variant has type() StringList, String , or List of a type that can be converted to QString; otherwise returns an empty list. More... | |
QTime | toTime () const |
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise returns an invalid time. More... | |
uint | toUInt (bool *ok=0) const |
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray , Char , Double , Int , LongLong , String , or ULongLong ; otherwise returns 0. More... | |
qulonglong | toULongLong (bool *ok=0) const |
Returns the variant as as an unsigned long long int if the variant has type() ULongLong , Bool , ByteArray , Char , Double , Int , LongLong , String , or UInt ; otherwise returns 0. More... | |
QUrl | toUrl () const |
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl. More... | |
Type | type () const |
Returns the storage type of the value stored in the variant. More... | |
const char * | typeName () const |
Returns the name of the type stored in the variant. More... | |
int | userType () const |
Returns the storage type of the value stored in the variant. More... | |
template<typename T > | |
T | value () const |
Returns the stored value converted to the template type T . More... | |
~QVariant () | |
Destroys the QVariant and the contained object. More... | |
bool | cmp (const QVariant &other) const |
void | create (int type, const void *copy) |
Static Private Functions inherited from QVariant | |
template<typename T > | |
static QVariant | fromValue (const T &value) |
Returns a QVariant containing a copy of value. More... | |
static Type | nameToType (const char *name) |
Converts the string representation of the storage type given in name, to its enum representation. More... | |
static const char * | typeToName (Type type) |
Converts the enum representation of the storage type, typ, to its string representation. More... | |
Properties inherited from QVariant | |
Private | d |
Static Private Attributes inherited from QVariant | |
static const Handler * | handler = &qt_kernel_variant_handler |
Related Functions inherited from QVariant | |
bool | operator!= (const QVariant &v1, const QVariant &v2) |
Returns false if v1 and v2 are equal; otherwise returns true. More... | |
bool | operator== (const QVariant &v1, const QVariant &v2) |
Returns true if v1 and v2 are equal; otherwise returns false. More... | |
T | qvariant_cast (const QVariant &value) |
Returns the given value converted to the template type T . More... | |
bool | qVariantCanConvert (const QVariant &value) |
Returns true if the given value can be converted to the template type specified; otherwise returns false. More... | |
QVariant | qVariantFromValue (const T &value) |
Returns a variant containing a copy of the given value with template type T . More... | |
QVariantHash | |
Synonym for QHash<QString, QVariant>. More... | |
QVariantList | |
Synonym for QList<QVariant>. More... | |
QVariantMap | |
Synonym for QMap<QString, QVariant>. More... | |
void | qVariantSetValue (QVariant &variant, const T &value) |
Sets the contents of the given variant to a copy of the value with the specified template type T . More... | |
T | qVariantValue (const QVariant &value) |
Returns the given value converted to the template type T . More... | |
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus typesystem.
A D-Bus function that takes an integer, a D-Bus variant and a string as parameters can be called with the following argument list (see QDBusMessage::setArguments()):
When a D-Bus function returns a D-Bus variant, it can be retrieved as follows:
The QVariant within a QDBusVariant is required to distinguish between a normal D-Bus value and a value within a D-Bus variant.
Definition at line 161 of file qdbusextratypes.h.
|
inline |
|
inlineexplicit |
Constructs a new D-Bus variant from the given Qt variant.
Definition at line 173 of file qdbusextratypes.h.
|
inline |
Assigns the value of the given Qt variant to this D-Bus variant.
Definition at line 176 of file qdbusextratypes.h.
|
inline |
Returns this D-Bus variant as a QVariant object.
Definition at line 169 of file qdbusextratypes.h.
Referenced by QDBusMarshaller::append(), operator==(), QConnmanEngine::propertyChangedContext(), qdbus_cast< QVariant >(), QConnmanEngine::servicePropertyChangedContext(), and QConnmanEngine::technologyPropertyChangedContext().