Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 953

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- dbus-adaptors.qdoc -->
  <title>The Qt D-Bus Type System | Qt D-Bus</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtdbus-index.html">Qt D-Bus</a></td><td >The Qt D-Bus Type System</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="qdbusdeclaringsignals.html" />
  <link rel="next" href="qdbusadaptorexample.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="qdbusdeclaringsignals.html">Declaring Signals in D-Bus Adaptors</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="qdbusadaptorexample.html">D-Bus Adaptor Example</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#primitive-types">Primitive Types</a></li>
<li class="level1"><a href="#compound-types">Compound Types</a></li>
<li class="level1"><a href="#extending-the-type-system">Extending the Type System</a></li>
<li class="level1"><a href="#the-type-system-in-use">The Type System in Use</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">The Qt D-Bus Type System</h1>
<span class="subtitle"></span>
<!-- $$$qdbustypesystem.html-description -->
<div class="descr"> <a name="details"></a>
<p>D-Bus has an extensible type system based on a few primitives and composition of the primitives in arrays and structures. Qt D-Bus 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 id="primitive-types">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>
<div class="table"><table class="generic">
 <thead><tr 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="../qtcore/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 >OBJECT_PATH</td></tr>
<tr valign="top" class="odd"><td ><a href="qdbussignature.html">QDBusSignature</a></td><td >SIGNATURE</td></tr>
</table></div>
<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="../qtcore/qstringlist.html">QStringList</a> and <a href="../qtcore/qbytearray.html">QByteArray</a>.</p>
<a name="compound-types"></a>
<h2 id="compound-types">Compound Types</h2>
<p>D-Bus specifies three types of aggregations of primitive types that allow one to create compound types. They are <code>ARRAY</code>, <code>STRUCT</code> 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 id="extending-the-type-system">Extending the Type System</h2>
<p>In order to use one's own type with Qt D-Bus, the type has to be declared as a Qt meta-type with the <a href="../qtcore/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 <code>operator&gt;&gt;</code> and <code>operator&lt;&lt;</code> will be automatically found by the registration system.</p>
<p>Qt D-Bus provides template specializations for arrays and maps for use with Qt's <a href="../qtcore/containers.html">container classes</a>, such as <a href="../qtcore/qmap.html">QMap</a> and <a href="../qtcore/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 id="the-type-system-in-use">The Type System in Use</h2>
<p>All of the Qt D-Bus 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="../qtcore/qlist.html">QList</a>&lt;<a href="../qtcore/qvariant.html">QVariant</a>&gt; and <a href="../qtcore/qmap.html">QMap</a>&lt;<a href="../qtcore/qstring.html">QString</a>,<a href="../qtcore/qvariant.html">QVariant</a>&gt;.</p>
</div>
<!-- @@@qdbustypesystem.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="qdbusdeclaringsignals.html">Declaring Signals in D-Bus Adaptors</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="qdbusadaptorexample.html">D-Bus Adaptor Example</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    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. </p>
</div>
</body>
</html>