1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the documentation of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:FDL$
10 ** GNU Free Documentation License
11 ** Alternatively, this file may be used under the terms of the GNU Free
12 ** Documentation License version 1.3 as published by the Free Software
13 ** Foundation and appearing in the file included in the packaging of
17 ** Alternatively, this file may be used in accordance with the terms
18 ** and conditions contained in a signed written agreement between you
26 ****************************************************************************/
29 \page datastreamformat.html
30 \title Serializing Qt Data Types
32 \brief Representations of data types that can be serialized by QDataStream.
34 The \l QDataStream allows you to serialize some of the Qt data types.
35 The table below lists the data types that QDataStream can serialize
36 and how they are represented. The format described below is
37 \l{QDataStream::setVersion()}{version 12}.
39 It is always best to cast integers to a Qt integer type, such as
40 qint16 or quint32, when reading and writing. This ensures that
41 you always know exactly what size integers you are reading and
42 writing, no matter what the underlying platform and architecture
43 the application happens to be running on.
56 \o signed 16-bit integer
60 \o signed 32-bit integer
64 \o signed 64-bit integer
72 \o unsigned 16-bit integer
76 \o unsigned 32-bit integer
80 \o unsigned 64-bit integer
84 \o 32-bit floating point number using the standard IEEE 754 format
88 \o 64-bit floating point number using the standard IEEE 754 format
90 \row \o \c {const char *}
92 \o The string length (quint32)
93 \o The string bytes, excluding the terminating 0
97 \o The array size (quint32)
98 \o The array bits, i.e. (size + 7)/8 bytes
102 \o The brush style (quint8)
103 \o The brush color (QColor)
104 \o If style is CustomPattern, the brush pixmap (QPixmap)
108 \o If the byte array is null: 0xFFFFFFFF (quint32)
109 \o Otherwise: the array size (quint32) followed by the array bytes, i.e. size bytes
113 \o Color spec (qint8)
114 \o Alpha value (quint16)
115 \o Red value (quint16)
116 \o Green value (quint16)
117 \o Blue value (quint16)
118 \o Pad value (quint16)
123 \o If shape is BitmapCursor: The bitmap (QPixmap), mask (QPixmap), and hot spot (QPoint)
127 \o Julian day (quint32)
133 \o 0 for Qt::LocalTime, 1 for Qt::UTC (quint8)
140 \o If hasConfig is true then these fields follow:
143 \o amplitude (double)
144 \o overshoot (double)
148 \o The family (QString)
149 \o The point size (qint16)
150 \o The style hint (quint8)
151 \o The char set (quint8)
152 \o The weight (quint8)
153 \o The font bits (quint8)
155 \row \o QHash<Key, T>
157 \o The number of items (quint32)
158 \o For all items, the key (Key) and value (T)
162 \o The number of pixmap entries (quint32)
163 \o For all pixmap entries:
165 \o The pixmap (QPixmap)
166 \o The file name (QString)
167 \o The pixmap size (QSize)
168 \o The \l{QIcon::Mode}{mode} (quint32)
169 \o The \l{QIcon::State}{state} (quint32)
174 \o If the image is null a "null image" marker is saved;
175 otherwise the image is saved in PNG or BMP format (depending
176 on the stream version). If you want control of the format,
177 stream the image into a QBuffer (using QImageIO) and stream
182 \o A QList<int>, where each integer is a key in the key sequence
184 \row \o QLinkedList<T>
186 \o The number of items (quint32)
191 \o The number of items (quint32)
196 \o The number of items (quint32)
197 \o For all items, the key (Key) and value (T)
227 \row \o QPair<T1, T2>
233 \o The disabled, active, and inactive color groups, each of which consists
236 \o foreground (QBrush)
243 \o brightText (QBrush)
244 \o buttonText (QBrush)
246 \o background (QBrush)
248 \o highlight (QBrush)
249 \o highlightedText (QBrush)
251 \o linkVisited (QBrush)
255 \o The pen styles (quint8)
256 \o The pen width (quint16)
257 \o The pen color (QColor)
261 \o The size of the picture data (quint32)
262 \o The raw bytes of picture data (char)
266 \o Save it as a PNG image.
270 \o The x coordinate (qint32)
271 \o The y coordinate (qint32)
275 \o The scalar component (double)
276 \o The x coordinate (double)
277 \o The y coordinate (double)
278 \o The z coordinate (double)
289 \o The regexp pattern (QString)
290 \o Case sensitivity (quint8)
291 \o Regular expression syntax (quint8)
292 \o Minimal matching (quint8)
296 \o The size of the data, i.e. 8 + 16 * (number of rectangles) (quint32)
298 \o The number of rectangles (quint32)
299 \o The rectangles in sequential order (QRect)
308 \o If the string is null: 0xFFFFFFFF (quint32)
309 \o Otherwise: The string length in bytes (quint32) followed by the data in UTF-16
313 \o Milliseconds since midnight (quint32)
329 \o Holds an URL (QString)
333 \o The type of the data (quint32)
334 \o The null flag (qint8)
335 \o The data of the specified type
339 \o the x coordinate (double)
340 \o the y coordinate (double)
344 \o the x coordinate (double)
345 \o the y coordinate (double)
346 \o the z coordinate (double)
350 \o the x coordinate (double)
351 \o the y coordinate (double)
352 \o the z coordinate (double)
353 \o the w coordinate (double)
357 \o The number of items (quint32)