<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/doc/src/qdbusadaptors.qdoc --> <head> <title>Qt 4.2: The QtDBus type system</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">The QtDBus type system<br /><small></small></h1> <p>D-BUS has an extensible type system based on a few primitives and composition of the primitives in arrays and structures. <a href="qtdbus.html">QtDBus</a> implements the interface to that type system through the <a href="qdbusargument.html">QDBusArgument</a> class, allowing user programs to send and receive practically every C++ type over the bus.</p> <a name="primitive-types"></a> <h2>Primitive types</h2> <p>The primitive types are supported natively by <a href="qdbusargument.html">QDBusArgument</a> and need no special customization to be sent or received. They are listed below, along with the C++ class they relate to:</p> <p><table align="center" cellpadding="2" cellspacing="1" border="0"> <thead><tr valign="top" class="qt-style"><th>Qt type</th><th>D-BUS equivalent type</th></tr></thead> <tr valign="top" class="odd"><td>uchar</td><td>BYTE</td></tr> <tr valign="top" class="even"><td>bool</td><td>BOOLEAN</td></tr> <tr valign="top" class="odd"><td>short</td><td>INT16</td></tr> <tr valign="top" class="even"><td>ushort</td><td>UINT16</td></tr> <tr valign="top" class="odd"><td>int</td><td>INT32</td></tr> <tr valign="top" class="even"><td>uint</td><td>UINT32</td></tr> <tr valign="top" class="odd"><td>qlonglong</td><td>INT64</td></tr> <tr valign="top" class="even"><td>qulonglong</td><td>UINT64</td></tr> <tr valign="top" class="odd"><td>double</td><td>DOUBLE</td></tr> <tr valign="top" class="even"><td><a href="qstring.html">QString</a></td><td>STRING</td></tr> <tr valign="top" class="odd"><td><a href="qdbusvariant.html">QDBusVariant</a></td><td>VARIANT</td></tr> <tr valign="top" class="even"><td><a href="qdbusobjectpath.html">QDBusObjectPath</a></td><td><a href="intro-to-dbus.html#object-paths">OBJECT_PATH</a></td></tr> <tr valign="top" class="odd"><td><a href="qdbussignature.html">QDBusSignature</a></td><td>SIGNATURE</td></tr> </table></p> <p>Aside from the primitive types, <a href="qdbusargument.html">QDBusArgument</a> also supports two non-primitive types natively, due to their widespread use in Qt applications: <a href="qstringlist.html">QStringList</a> and <a href="qbytearray.html">QByteArray</a>.</p> <a name="compound-types"></a> <h2>Compound types</h2> <p>D-BUS specifies three types of aggregations of primitive types that allow one to create compound types. They are <tt>ARRAY</tt>, <tt>STRUCT</tt> and maps/dictionaries.</p> <p>Arrays are sets of zero or more elements of the same type, while structures are a set of a fixed number of elements, each of any type. Maps or dictionaries are implemented as arrays of a pair of elements, so there can be zero or more elements in one map.</p> <a name="extending-the-type-system"></a> <h2>Extending the type system</h2> <p>In order to use one's own type with <a href="qtdbus.html">QtDBus</a>, the type has to be declared as a Qt Meta Type with the <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a>() macro and then registered with the <a href="qdbusargument.html#qDBusRegisterMetaType">qDBusRegisterMetaType</a>() function. The streaming operators <tt>operator>></tt> and <tt>operator<<</tt> will be automatically found by the registration system.</p> <p><a href="qtdbus.html">QtDBus</a> provides template specializations for arrays and maps for use with Qt's <a href="containers.html">Container classes</a>, such as <a href="qmap.html">QMap</a> and <a href="qlist.html">QList</a>, so it is not necessary to write the streaming operator functions for those. For other types and specially for types implementing structures, however, the operators have to be explicitly implemented.</p> <p>See the documentation for <a href="qdbusargument.html">QDBusArgument</a> for examples for structures, arrays and maps.</p> <a name="type-system-in-use"></a> <h2>Type system in use</h2> <p>All of the <a href="qtdbus.html">QtDBus</a> types (primitives and user-defined alike) can be used to send and receive messages of all types over the bus.</p> <p><b>Warning:</b> You may not use any type that is not on the list above, including <i>typedefs</i> to the types listed. This also includes <a href="qlist.html">QList</a><<a href="qvariant.html">QVariant</a>> and <a href="qmap.html">QMap</a><<a href="qstring.html">QString</a>,<a href="qvariant.html">QVariant</a>>.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="30%">Copyright © 2006 <a href="trolltech.html">Trolltech</a></td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.2.1</div></td> </tr></table></div></address></body> </html>