CopperSpice API  1.9.1
Serializing Data Types

The QDataStream allows you to serialize various data types. The table below lists the data types QDataStream can serialize.

It is always best to cast integers to a specific integer type such as qint16 or quint32 when reading and writing. This ensures the integer is a consistent size regardless of your platform or architecture.

bool boolean
qint8 signed 8-bit integer
qint16 signed 16-bit integer
qint32 signed 32-bit integer
qint64 signed 64-bit integer
quint8 unsigned 8-bit integer
quint16 unsigned 16-bit integer
quint32 unsigned 32-bit integer
quint64 unsigned 64-bit integer
float IEEE 754 32-bit floating point number
double IEEE 754 64-bit floating point number
const char * string length (quint32), string bytes, excluding the terminating 0
QBitArray array size (quint32), array bits
QBrush brush style (quint8), brush style (QColor), if style is CustomPattern the brush pixmap (QPixmap)
QByteArray array size (quint32) followed by the array data, or 0xFFFFFFFF if null
QColor color spec (qint8), alpha (quint16),
red (quint16), green (quint16), blue (quint16),
pad value (quint16)
QCursor shape ID (qint16), if shape is BitmapCursor the bitmap (QPixmap), mask (QPixmap), and hot spot (QPoint)
QDate julian day (quint32)
QDateTime date (QDate), time (QTime), Qt::TimeSpec (qint8)
QEasingCurve type (quint8), func (quint64), hasConfig (bool), if hasConfig is true the following three fields:
period (double), amplitude (double), overshoot (double)
QFont family (QString), point size (qint16), style hint (quint8),
char set (quint8), weight (quint8), font bits (quint8)
QHash number of items (quint32), the items of type Key and Value
QIcon number of pixmap entries (quint32),
for each pixmap entry the following five fields: pixmap (QPixmap), file name (QString),
pixmap size (QSize), QIcon::Mode (quint32), QIcon::State (quint32)
QImage if the image is null 0 (qint32), otherwise a 1 (qint32),
the image in PNG or BMP format (depending on the stream version)
QKeySequence QList<int>, where each integer is a key in the key sequence
QLinkedList number of items (quint32), the items of type T
QList number of items (quint32), the items of type T
QMap number of items (quint32), the items of type Key and Value
QMatrix m11 (double), m12 (double), m21 (double), m22 (double), dx (double), dy (double)
QMatrix4x4 m11 (float), m12 (float), m13 (float), m14 (float),
m21 (float), m22 (float), m23 (float), m24 (float),
m31 (float), m32 (float), m33 (float), m34 (float),
m41 (float), m42 (float), m43 (float), m44 (float)
QMultiHash number of items (quint32), the items of type Key and Value
QMultiMap number of items (quint32), the items of type Key and Value
QPair first (T1), second (T2)
QPalette disabled, active, and inactive color groups, each of which consists of the following:
QPen pen styles (quint8), pen width (quint16), pen color (QColor)
QPicture size of the picture data (quint32), raw bytes of picture data (char)
QPixmap save it as a PNG image
QPoint x coordinate (qint32), y coordinate (qint32)
QQuaternion scalar component (float), x coordinate (float), y coordinate (float), z coordinate (float)
QRect left (qint32), top (qint32), right (qint32), bottom (qint32)
QRegularExpression regular expression pattern (QString), pattern options (quint32)
QRegion size of the data [ 8 + 16 * (number of rectangles) ] (quint32),
10 (qint32), number of rectangles (quint32), rectangles in sequential order (QRect)
QSize width (qint32), height (qint32)
QString array size (quint32) followed by the array data, or 0xFFFFFFFF if null
QString8 array size (quint32) followed by the array data, or 0xFFFFFFFF if null
QTime milliseconds since midnight (quint32)
QTransform m11 (double), m12 (double), m13 (double),
m21 (double), m22 (double), m23 (double),
m31 (double), m32 (double), m33 (double)
QUrl holds a URL (QString)
QVariant type of the data (quint32), null flag (qint8), data of the specified type
QVector2D x coordinate (float), y coordinate (float)
QVector3D x coordinate (float), y coordinate (float), z coordinate (float)
QVector4D x coordinate (float), y coordinate (float), z coordinate (float), w coordinate (float)
QVector number of items (quint32), the items of type T