Qt 4.8
Public Functions | List of all members
QDBusVariant Class Reference

The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus typesystem. More...

#include <qdbusextratypes.h>

Inheritance diagram for QDBusVariant:
QVariant

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
 
DataPtrdata_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...
 
QVariantoperator= (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 &regExp)
 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, QVarianttoHash () 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< QVarianttoList () 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, QVarianttoMap () 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 >
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
 

Detailed Description

The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus typesystem.

Attention
Module: QtDBus
Since
4.2

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()):

QList<QVariant> arguments;
arguments << QVariant(42) << QVariant::fromValue(QDBusVariant(43)) << QVariant("hello");
myDBusMessage.setArguments(arguments);

When a D-Bus function returns a D-Bus variant, it can be retrieved as follows:

// call a D-Bus function that returns a D-Bus variant
QVariant v = callMyDBusFunction();
// retrieve the D-Bus variant
// retrieve the actual value stored in the D-Bus variant
QVariant result = dbusVariant.variant();

The QVariant within a QDBusVariant is required to distinguish between a normal D-Bus value and a value within a D-Bus variant.

See also
{The QtDBus type system}

Definition at line 161 of file qdbusextratypes.h.

Constructors and Destructors

◆ QDBusVariant() [1/2]

QDBusVariant::QDBusVariant ( )
inline

Constructs a new D-Bus variant.

Definition at line 164 of file qdbusextratypes.h.

164 { }

◆ QDBusVariant() [2/2]

QDBusVariant::QDBusVariant ( const QVariant variant)
inlineexplicit

Constructs a new D-Bus variant from the given Qt variant.

See also
setVariant()

Definition at line 173 of file qdbusextratypes.h.

174  : QVariant(dBusVariant) { }
QVariant()
Constructs an invalid variant.
Definition: qvariant.h:484

Functions

◆ setVariant()

void QDBusVariant::setVariant ( const QVariant variant)
inline

Assigns the value of the given Qt variant to this D-Bus variant.

See also
variant()

Definition at line 176 of file qdbusextratypes.h.

177 { QVariant::operator=(dBusVariant); }
QVariant & operator=(const QVariant &other)
Assigns the value of the variant variant to this variant.
Definition: qvariant.cpp:1921

◆ variant()

QVariant QDBusVariant::variant ( ) const
inline

The documentation for this class was generated from the following files: