It is always best to cast integers to a Qt integer type when writing, and to read back into the same Qt integer type when reading.
Using Qt's integer types ensures that you always know exactly what size integers you are reading and writing, no matter what the underlying platform and architecture (e.g. 32-bit or 64-bit) the application happens to be running on.
Q_INT8 |
|
Q_INT16 |
|
Q_INT32 |
|
Q_INT64 |
|
Q_UINT8 |
|
Q_UINT16 |
|
Q_UINT32 |
|
Q_UINT64 |
|
float |
- 32-bit floating point number using the standard IEEE 754 format
|
double |
- 64-bit floating point number using the standard IEEE 754 format
|
const char * |
- The size of the string including the terminating 0 (Q_UINT32)
- The string bytes including the terminating 0
The null string is represented as (Q_UINT32)0. |
QBitArray |
- The array size (Q_UINT32)
- The array bits, i.e. (size + 7)/8 bytes
|
QBrush |
- The brush style (Q_UINT8)
- The brush color (QColor)
- If style is CustomPattern, the brush pixmap (QPixmap)
|
QByteArray |
- If the byte array is null: 0xFFFFFFFF (Q_UINT32)
- Otherwise: the array size (Q_UINT32) followed by the array bytes, i.e. size bytes
|
QColor |
- RGB value serialized as a Q_UINT32
|
QCoreVariant |
- The type of the data (Q_UINT32)
- The data of the specified type
|
QCursor |
- Shape ID (Q_INT16)
- If shape is BitmapCursor: The bitmap (QPixmap), mask (QPixmap), and hot spot (QPoint)
|
QDate |
|
QDateTime |
- Date (QDate)
- Time (QTime)
|
QFont |
- The family (QString)
- The point size (Q_INT16)
- The style hint (Q_UINT8)
- The char set (Q_UINT8)
- The weight (Q_UINT8)
- The font bits (Q_UINT8)
|
QHash<Key, T> |
- The number of items (Q_UINT32)
- For all items, the key (Key) and value (T)
|
QImage |
- If the image is null a "null image" 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 QBuffer (using QImageIO) and stream that.
|
QKeySequence | A QList<int>, where each integer is a key in the key sequence |
QLinkedList<T> |
- The number of items (Q_UINT32)
- The items (T)
|
QList<T> |
- The number of items (Q_UINT32)
- The items (T)
|
QMap<Key, T> |
- The number of items (Q_UINT32)
- For all items, the key (Key) and value (T)
|
QPair<T1, T2> |
|
QPalette | The disabled, active, and inactive color groups, each of which consists of the following:
- foreground (QBrush)
- button (QBrush)
- light (QBrush)
- midlight (QBrush)
- dark (QBrush)
- mid (QBrush)
- text (QBrush)
- brightText (QBrush)
- buttonText (QBrush)
- base (QBrush)
- background (QBrush)
- shadow (QBrush)
- highlight (QBrush)
- highlightedText (QBrush)
- link (QBrush)
- linkVisited (QBursh)
|
QPen |
- The pen styles (Q_UINT8)
- The pen width (Q_UINT16)
- The pen color (QColor)
|
QPicture |
- The size of the picture data (Q_UINT32)
- The raw bytes of picture data (char)
|
QPixmap |
|
QPoint |
- The x coordinate (Q_INT32)
- The y coordinate (Q_INT32)
|
QPointArray |
- The array size (Q_UINT32)
- The array points (QPoint)
|
QRect |
- left (Q_INT32)
- top (Q_INT32)
- right (Q_INT32)
- bottom (Q_INT32)
|
QRegion |
- The size of the data, i.e. 8 + 16 * (number of rectangles) (Q_UINT32)
- QRGN_RECTS (Q_INT32)
- The number of rectangles (Q_UINT32)
- The rectangles in sequential order (QRect)
|
QSize |
- width (Q_INT32)
- height (Q_INT32)
|
QString |
- If the string is null: 0xFFFFFFFF (Q_UINT32)
- Otherwise: The string length (Q_UINT32) followed by the data in UTF-16
|
QTime |
- Milliseconds since midnight (Q_UINT32)
|
QVector<T> |
- The number of items (Q_UINT32)
- The items (T)
|
QWMatrix |
- m11 (double)
- m12 (double)
- m21 (double)
- m22 (double)
- dx (double)
- dy (double)
|