序列化Qt数据类型

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wyy626562203/article/details/82735436

序列化Qt数据类型

Qt 5.10.1

QDataStream允许您序列化一些Qt数据类型。下表列出了QDataStream可以序列化的数据类型以及它们的表示方式。下面描述的格式是版本13。
在读取和写入时,最好将整数转换为Qt整数类型,例如qint16或quint32。 这可确保您始终确切知道正在读取和写入的整数大小,无论应用程序正在运行的底层平台和体系结构如何。

类型 描述
bool boolean
qint8 signed byte
qint16 signed 16-bit integer
qint32 signed 32-bit integer
qint64 signed 64-bit integer
quint8 unsigned byte
quint16 unsigned 16-bit integer
quint32 unsigned 32-bit integer
quint64 unsigned 64-bit integer
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 string length (quint32)
The string bytes, excluding the terminating 0
QBitArray The array size (quint32)
The array bits, i.e. (size + 7)/8 bytes
QBrush The brush style (quint8)
The brush color (QColor)
If style is CustomPattern, the brush pixmap (QPixmap)
QByteArray If the byte array is null: 0xFFFFFFFF (quint32)
Otherwise: the array size (quint32) followed by the array bytes, i.e. size bytes
QColor Color spec (qint8)
Alpha value (quint16)
Red value (quint16)
Green value (quint16)
Blue value (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)
The time spec offsetFromUtc (qint32) if Qt::TimeSpec is offsetFromUtc TimeZone(QTimeZone) if Qt::TimeSpec is TimeZone
QEasingCurve type (quint8)
func (quint64)
hasConfig (bool)
If hasConfig is true then these fields follow:
list
period (double)
amplitude (double)
overshoot (double)
QFont The family (QString)
The style name (QString)
The point size (double)
The pixel size (qint32)
The style hint (quint8)
The style strategy (quint16)
The char set (quint8)
The weight (quint8)
The font bits (quint8)
The font stretch (quint16)
The extended font bits (quint8)
The letter spacing (double)
The word spacing (double)
The hinting preference (quint8)
QHash The number of items (quint32)
For all items, the key (Key) and value (T)
QIcon The number of pixmap entries (quint32)
For all pixmap entries:
The pixmap (QPixmap)
The file name (QString)
The pixmap size (QSize)
The mode (quint32)
The state (quint32)
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 QImageIOHandler/QImageIOPlugin) and stream that.
QKeySequence A QList, where each integer is a key in the key sequence
QLinkedList The number of items (quint32)
The items (T)
QList The number of items (quint32)
The items (T)
QMap The number of items (quint32)
For all items, the key (Key) and value (T)
QMargins left (int)
top (int)
right (int)
bottom (int)
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)
QPair first (T1) second (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 (QBrush)
QPen The pen styles (quint8)
The pen width (quint16)
The pen color (QColor)
QPicture The size of the picture data (quint32)
The raw bytes of picture data (char)
QPixmap Save it as a PNG image.
QPoint The x coordinate (qint32)
The y coordinate (qint32)
QQuaternion The scalar component (float)
The x coordinate (float)
The y coordinate (float)
The z coordinate (float)
QRect left (qint32) top (qint32) right (qint32) bottom (qint32)
QRegExp The regexp pattern (QString)
Case sensitivity (quint8)
Regular expression syntax (quint8)
Minimal matching (quint8)
QRegularExpression The regular expression pattern (QString)
The pattern options (quint32)
QRegion The size of the data, i.e. 8 + 16 * (number of rectangles) (quint32)
10 (qint32)
The number of rectangles (quint32)
The rectangles in sequential order (QRect)
QSize width (qint32)
height (qint32)
QString If the string is null: 0xFFFFFFFF (quint32)
Otherwise: The string length in bytes (quint32) followed by the data in UTF-16
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 an URL (QString)
QVariant The type of the data (quint32)
The null flag (qint8)
The data of the specified type
QVector2D the x coordinate (float)
the y coordinate (float)
QVector3D the x coordinate (float)
the y coordinate (float)
the z coordinate (float)
QVector4D the x coordinate (float)
the y coordinate (float)
the z coordinate (float)
the w coordinate (float)
QVector The number of items (quint32)
The items (T)

猜你喜欢

转载自blog.csdn.net/wyy626562203/article/details/82735436