datastreamformat.html 15.3 KB
Newer Older
xuebingbing's avatar
xuebingbing committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- datastreamformat.qdoc -->
  <title>Serializing Qt Data Types | Qt Core 5.11</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 ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtcore-index.html">Qt Core</a></td><td >Serializing Qt Data Types</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.11.2 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Serializing Qt Data Types</h1>
<span class="subtitle"></span>
<!-- $$$datastreamformat.html-description -->
<div class="descr"> <a name="details"></a>
<p>The <a href="qdatastream.html">QDataStream</a> allows you to serialize some of the Qt data types. The table below lists the data types that <a href="qdatastream.html">QDataStream</a> can serialize and how they are represented. The format described below is <a href="qdatastream.html#setVersion">version 13</a>.</p>
<p>It is always best to cast integers to a Qt integer type, such as qint16 or quint32, when reading and writing. This ensures that you always know exactly what size integers you are reading and writing, no matter what the underlying platform and architecture the application happens to be running on.</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td >bool</td><td ><ul>
<li>boolean</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td >qint8</td><td ><ul>
<li>signed byte</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td >qint16</td><td ><ul>
<li>signed 16-bit integer</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td >qint32</td><td ><ul>
<li>signed 32-bit integer</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td >qint64</td><td ><ul>
<li>signed 64-bit integer</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td >quint8</td><td ><ul>
<li>unsigned byte</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td >quint16</td><td ><ul>
<li>unsigned 16-bit integer</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td >quint32</td><td ><ul>
<li>unsigned 32-bit integer</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td >quint64</td><td ><ul>
<li>unsigned 64-bit integer</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><code>float</code></td><td ><ul>
<li>32-bit floating point number using the standard IEEE 754 format</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><code>double</code></td><td ><ul>
<li>64-bit floating point number using the standard IEEE 754 format</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><code>const char *</code></td><td ><ul>
<li>The string length (quint32)</li>
<li>The string bytes, excluding the terminating 0</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qbitarray.html">QBitArray</a></td><td ><ul>
<li>The array size (quint32)</li>
<li>The array bits, i.e&#x2e; (size + 7)/8 bytes</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qbrush.html">QBrush</a></td><td ><ul>
<li>The brush style (quint8)</li>
<li>The brush color (<a href="../qtgui/qcolor.html">QColor</a>)</li>
<li>If style is CustomPattern, the brush pixmap (<a href="../qtgui/qpixmap.html">QPixmap</a>)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qbytearray.html">QByteArray</a></td><td ><ul>
<li>If the byte array is null: 0xFFFFFFFF (quint32)</li>
<li>Otherwise: the array size (quint32) followed by the array bytes, i.e&#x2e; size bytes</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qcolor.html">QColor</a></td><td ><ul>
<li>Color spec (qint8)</li>
<li>Alpha value (quint16)</li>
<li>Red value (quint16)</li>
<li>Green value (quint16)</li>
<li>Blue value (quint16)</li>
<li>Pad value (quint16)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qcursor.html">QCursor</a></td><td ><ul>
<li>Shape ID (qint16)</li>
<li>If shape is BitmapCursor: The bitmap (<a href="../qtgui/qpixmap.html">QPixmap</a>), mask (<a href="../qtgui/qpixmap.html">QPixmap</a>), and hot spot (<a href="qpoint.html">QPoint</a>)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qdate.html">QDate</a></td><td ><ul>
<li>Julian day (quint32)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qdatetime.html">QDateTime</a></td><td ><ul>
<li>Date (<a href="qdate.html">QDate</a>)</li>
<li>Time (<a href="qtime.html">QTime</a>)</li>
<li>The <a href="qt.html#TimeSpec-enum">time spec</a> offsetFromUtc (qint32) if <a href="qt.html#TimeSpec-enum">Qt::TimeSpec</a> is offsetFromUtc TimeZone(<a href="qtimezone.html">QTimeZone</a>) if <a href="qt.html#TimeSpec-enum">Qt::TimeSpec</a> is TimeZone</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qeasingcurve.html">QEasingCurve</a></td><td ><ul>
<li>type (quint8)</li>
<li>func (quint64)</li>
<li>hasConfig (bool)</li>
<li>If hasConfig is true then these fields follow:</li>
<li>list</li>
<li>period (double)</li>
<li>amplitude (double)</li>
<li>overshoot (double)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qfont.html">QFont</a></td><td ><ul>
<li>The family (<a href="qstring.html">QString</a>)</li>
<li>The style name (<a href="qstring.html">QString</a>)</li>
<li>The point size (double)</li>
<li>The pixel size (qint32)</li>
<li>The style hint (quint8)</li>
<li>The style strategy (quint16)</li>
<li>The char set (quint8)</li>
<li>The weight (quint8)</li>
<li>The font bits (quint8)</li>
<li>The font stretch (quint16)</li>
<li>The extended font bits (quint8)</li>
<li>The letter spacing (double)</li>
<li>The word spacing (double)</li>
<li>The hinting preference (quint8)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qhash.html#qhash">QHash</a>&lt;Key, T&gt;</td><td ><ul>
<li>The number of items (quint32)</li>
<li>For all items, the key (Key) and value (T)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qicon.html">QIcon</a></td><td ><ul>
<li>The number of pixmap entries (quint32)</li>
<li>For all pixmap entries:<ul>
<li>The pixmap (<a href="../qtgui/qpixmap.html">QPixmap</a>)</li>
<li>The file name (<a href="qstring.html">QString</a>)</li>
<li>The pixmap size (<a href="qsize.html">QSize</a>)</li>
<li>The <a href="../qtgui/qicon.html#Mode-enum">mode</a> (quint32)</li>
<li>The <a href="../qtgui/qicon.html#State-enum">state</a> (quint32)</li>
</ul>
</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qimage.html">QImage</a></td><td ><ul>
<li>If the image is null a &quot;null image&quot; marker is saved; otherwise the image is saved in PNG or BMP format (depending on the stream version). If you want control of the format, stream the image into a <a href="qbuffer.html">QBuffer</a> (using <a href="../qtgui/qimageiohandler.html">QImageIOHandler</a>/<a href="../qtgui/qimageioplugin.html">QImageIOPlugin</a>) and stream that.</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qkeysequence.html">QKeySequence</a></td><td ><ul>
<li>A <a href="qlist.html">QList</a>&lt;int&gt;, where each integer is a key in the key sequence</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qlinkedlist.html">QLinkedList</a>&lt;T&gt;</td><td ><ul>
<li>The number of items (quint32)</li>
<li>The items (T)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qlist.html">QList</a>&lt;T&gt;</td><td ><ul>
<li>The number of items (quint32)</li>
<li>The items (T)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qmap.html">QMap</a>&lt;Key, T&gt;</td><td ><ul>
<li>The number of items (quint32)</li>
<li>For all items, the key (Key) and value (T)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qmargins.html">QMargins</a></td><td ><ul>
<li>left (int)</li>
<li>top (int)</li>
<li>right (int)</li>
<li>bottom (int)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td >QMatrix</td><td ><ul>
<li>m11 (double)</li>
<li>m12 (double)</li>
<li>m21 (double)</li>
<li>m22 (double)</li>
<li>dx (double)</li>
<li>dy (double)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qmatrix4x4.html">QMatrix4x4</a></td><td ><ul>
<li>m11 (float)</li>
<li>m12 (float)</li>
<li>m13 (float)</li>
<li>m14 (float)</li>
<li>m21 (float)</li>
<li>m22 (float)</li>
<li>m23 (float)</li>
<li>m24 (float)</li>
<li>m31 (float)</li>
<li>m32 (float)</li>
<li>m33 (float)</li>
<li>m34 (float)</li>
<li>m41 (float)</li>
<li>m42 (float)</li>
<li>m43 (float)</li>
<li>m44 (float)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qpair.html">QPair</a>&lt;T1, T2&gt;</td><td ><ul>
<li>first (T1)</li>
<li>second (T2)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qpalette.html">QPalette</a></td><td >The disabled, active, and inactive color groups, each of which consists of the following:<ul>
<li>foreground (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>button (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>light (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>midlight (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>dark (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>mid (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>text (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>brightText (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>buttonText (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>base (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>background (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>shadow (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>highlight (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>highlightedText (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>link (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
<li>linkVisited (<a href="../qtgui/qbrush.html">QBrush</a>)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qpen.html">QPen</a></td><td ><ul>
<li>The pen styles (quint8)</li>
<li>The pen width (quint16)</li>
<li>The pen color (<a href="../qtgui/qcolor.html">QColor</a>)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qpicture.html">QPicture</a></td><td ><ul>
<li>The size of the picture data (quint32)</li>
<li>The raw bytes of picture data (char)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qpixmap.html">QPixmap</a></td><td ><ul>
<li>Save it as a PNG image.</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qpoint.html">QPoint</a></td><td ><ul>
<li>The x coordinate (qint32)</li>
<li>The y coordinate (qint32)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qquaternion.html">QQuaternion</a></td><td ><ul>
<li>The scalar component (float)</li>
<li>The x coordinate (float)</li>
<li>The y coordinate (float)</li>
<li>The z coordinate (float)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qrect.html">QRect</a></td><td ><ul>
<li>left (qint32)</li>
<li>top (qint32)</li>
<li>right (qint32)</li>
<li>bottom (qint32)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qregexp.html">QRegExp</a></td><td ><ul>
<li>The regexp pattern (<a href="qstring.html">QString</a>)</li>
<li>Case sensitivity (quint8)</li>
<li>Regular expression syntax (quint8)</li>
<li>Minimal matching (quint8)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qregularexpression.html">QRegularExpression</a></td><td ><ul>
<li>The regular expression pattern (<a href="qstring.html">QString</a>)</li>
<li>The pattern options (quint32)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qregion.html">QRegion</a></td><td ><ul>
<li>The size of the data, i.e&#x2e; 8 + 16 * (number of rectangles) (quint32)</li>
<li>10 (qint32)</li>
<li>The number of rectangles (quint32)</li>
<li>The rectangles in sequential order (<a href="qrect.html">QRect</a>)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qsize.html">QSize</a></td><td ><ul>
<li>width (qint32)</li>
<li>height (qint32)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qstring.html">QString</a></td><td ><ul>
<li>If the string is null: 0xFFFFFFFF (quint32)</li>
<li>Otherwise: The string length in bytes (quint32) followed by the data in UTF-16</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qtime.html">QTime</a></td><td ><ul>
<li>Milliseconds since midnight (quint32)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qtransform.html">QTransform</a></td><td ><ul>
<li>m11 (double)</li>
<li>m12 (double)</li>
<li>m13 (double)</li>
<li>m21 (double)</li>
<li>m22 (double)</li>
<li>m23 (double)</li>
<li>m31 (double)</li>
<li>m32 (double)</li>
<li>m33 (double)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="qurl.html">QUrl</a></td><td ><ul>
<li>Holds an URL (<a href="qstring.html">QString</a>)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qvariant.html">QVariant</a></td><td ><ul>
<li>The type of the data (quint32)</li>
<li>The null flag (qint8)</li>
<li>The data of the specified type</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qvector2d.html">QVector2D</a></td><td ><ul>
<li>the x coordinate (float)</li>
<li>the y coordinate (float)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="../qtgui/qvector3d.html">QVector3D</a></td><td ><ul>
<li>the x coordinate (float)</li>
<li>the y coordinate (float)</li>
<li>the z coordinate (float)</li>
</ul>
</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtgui/qvector4d.html">QVector4D</a></td><td ><ul>
<li>the x coordinate (float)</li>
<li>the y coordinate (float)</li>
<li>the z coordinate (float)</li>
<li>the w coordinate (float)</li>
</ul>
</td></tr>
<tr valign="top" class="even"><td ><a href="qvector.html">QVector</a>&lt;T&gt;</td><td ><ul>
<li>The number of items (quint32)</li>
<li>The items (T)</li>
</ul>
</td></tr>
</table></div>
</div>
<p><b>See also </b><a href="json.html">JSON Support in Qt</a>.</p>
<!-- @@@datastreamformat.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2018 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>