Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 3892

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?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">
<!-- dbus-adaptors.qdoc -->
<head>
  <title>Qt 4.6: The QtDBus Type System</title>
  <link rel="prev" href="qdbusdeclaringsignals.html" />
  <link rel="contents" href="usingadaptors.html" />
  <link rel="next" href="qdbusadaptorexample.html" />
  <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://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><p>
[Previous: <a href="qdbusdeclaringsignals.html">Declaring Signals in D-Bus Adaptors</a>]
[<a href="usingadaptors.html">Using QtDBus Adaptors</a>]
[Next: <a href="qdbusadaptorexample.html">D-Bus Adaptor Example</a>]
</p>
<h1 class="title">The QtDBus Type System<br /><span class="subtitle"></span>
</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 class="generic" 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 registered with the <a href="qdbusargument.html#qDBusRegisterMetaType">qDBusRegisterMetaType</a>() function. The streaming operators <tt>operator&gt;&gt;</tt> and <tt>operator&lt;&lt;</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">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, 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="the-type-system-in-use"></a>
<h2>The 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>&lt;<a href="qvariant.html">QVariant</a>&gt; and <a href="qmap.html">QMap</a>&lt;<a href="qstring.html">QString</a>,<a href="qvariant.html">QVariant</a>&gt;.</p>
<p>
[Previous: <a href="qdbusdeclaringsignals.html">Declaring Signals in D-Bus Adaptors</a>]
[<a href="usingadaptors.html">Using QtDBus Adaptors</a>]
[Next: <a href="qdbusadaptorexample.html">D-Bus Adaptor Example</a>]
</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>