QT QTextStream QDataStream のテキストおよびバイナリ データの操作メソッド

QTextStream クラス

詳細な説明

QTextStream は、 QIODeviceQByteArray  、またはQString上で動作できますQTextStream のストリーミング オペレーターを使用すると、単語、行、数字を簡単に読み書きできます。テキストを生成する場合、QTextStream はフィールドのパディングと位置合わせの書式設定オプション、および数値の書式設定をサポートしています。例:

QTextStream は、QIODevice、QByteArray、または QString 上で動作できます。QTextStream のストリーム演算子を使用すると、単語、行、数値を簡単に読み書きできます。テキストを生成する場合、QTextStream は数値の書式設定だけでなく、フィールドのパディングと位置合わせの書式設定オプションもサポートしています。例:

  QFile  data("output.txt");

  if (data.open( QFile ::WriteOnly | QFile ::Truncate)) {

      QTextStream  out(&data);

      out << "結果: " << qSetFieldWidth (10) << left << 3.14 << 2.7;

      // 「結果: 3.14 2.7」を書き込みます

  }

QTextStream を使用してコンソール入力を読み取り、コンソール出力を書き込むことも一般的です。QTextStream はロケールを認識し、正しいコーデックを使用して標準入力を自動的にデコードします。例:

QTextStream を使用してコンソール入力を読み取り、コンソール出力を書き込むことも一般的です。QTextStream はロケールを認識し、正しいコーデックを使用して標準入力を自動的にデコードします。サンプル

  QTextStream ストリーム(標準入力);

  QString 行;

  while (stream.readLineInto(&line)) {

      ...

  }

QTextStream のコンストラクターを使用する以外に、 setDevice () またはsetString ()を呼び出して、QTextStream が操作するデバイスまたは文字列を設定することもできます。位置をシークするには、 seek ()を呼び出します。読み取るデータがなくなった場合、atEnd () は true を返します。lush ()を呼び出すと、QTextStreamは書き込みバッファからデバイスへのすべてのデータを空にし、デバイス上でflush ()を呼び出します。

QTextStream のコンストラクターを使用することに加えて、setDevice() または setString() を呼び出して、QTextStream が操作するデバイスまたは文字列を設定することもできます。位置は、seek() を呼び出すことで見つけることができます。読み取るデータがない場合、atEnd() は true を返します。flash() が呼び出された場合、QTextStream はデバイスへの書き込みバッファ内のすべてのデータをクリアし、デバイス上で flash() を呼び出します。

内部的には、QTextStream は Unicode ベースのバッファーを使用し、QTextCodec は 異なる文字セットを自動的にサポートするために QTextStream によって使用されます。デフォルトでは、QTextCodec::codecForLocale () が読み取りと書き込みに使用されますが、setCodec () を呼び出してコーデックを設定することもできます。Unicode の自動検出もサポートされています。この機能が有効になっている場合 (デフォルトの動作)、QTextStream は UTF-16 または UTF-32 BOM (バイト オーダー マーク) を検出し、読み取り時に適切な UTF コーデックに切り替えます。QTextStream はデフォルトでは BOM を書き込みませんが、setGenerateByteOrderMark (true) を呼び出すことでこれを有効にできます。QTextStream がQStringに対して 直接動作する場合、コーデックは無効になります。

内部的には、QTextStream は Unicode ベースのバッファーを使用し、QTextCodec は異なる文字セットを自動的にサポートするために QTextStream によって使用されます。デフォルトでは、QTextCodec::codecForLocale() が読み取りと書き込みに使用されますが、setCodec() を呼び出してコーデックを設定することもできます。Unicode の自動検出もサポートされています。この機能が有効になっている場合 (デフォルトの動作)、QTextStream は UTF-16 または UTF-32 BOM (バイト オーダー マーク) を検出し、読み取り時に適切な UTF コーデックに切り替えます。QTextStream はデフォルトでは BOM を書き込みませんが、setGenerateByteOrderMark(true) を呼び出すことで有効にできます。QTextStream が QString に対して直接動作する場合、コーデックは無効になります。

テキスト ファイルを読み取るときに QTextStream を使用するには、次の 3 つの一般的な方法があります。

テキスト ファイルを読み取る場合、QTextStream を使用するには通常 3 つの方法があります。

  • readLine () またはreadAll ()を呼び出して、チャンクごとに分割します。
  • readLine() または readAll() をブロックごとに呼び出します。
  • 一語一語。QTextStream は、 QStringQByteArray 、および char* バッファへのストリーミングをサポートします単語はスペースで区切られ、先頭の空白は自動的にスキップされます。
  • 一言一句。QTextStream は、qstring、QByteArray、char* バッファへのストリーミングをサポートします。単語はスペースで区切られ、先頭の空白は自動的にスキップされます。
  • QCharまたは char 型にストリーミングすることにより、文字ごとに 。このメソッドは、文字エンコーディングや行末のセマンティクスに関係なく、ファイルを解析する際の便利な入力処理のためによく使用されます。空白をスキップするには、skipWhiteSpace ()を呼び出します。
  • QChar または char 型にストリーミングすることにより、文字ごとに。このメソッドは通常、文字エンコーディングや行末のセマンティクスに関係なく、ファイルを解析する際の便利な入力処理のために使用されます。空白をスキップするには、skipWhiteSpace() を呼び出します。

テキスト ストリームはバッファを使用するため、スーパークラスの実装を使用してストリームから読み取らないでください。たとえば、QFile があり、ストリームを使用する代わりにQFile::readLine () を使用して直接読み取る場合、テキスト ストリームの内部位置はファイルの位置と同期しなくなります。

テキスト ストリームはバッファを使用するため、ストリームから読み取るためにスーパークラスの実装を使用しないでください。たとえば、QFile があり、ストリームを使用する代わりに QFile::readLine() を使用して直接読み取る場合、テキスト ストリームの内部位置はファイルの位置と同期しなくなります。

デフォルトでは、テキストのストリームから数値を読み取るときに、QTextStream は数値の基本表現を自動的に検出します。たとえば、数値が「0x」で始まる場合は、16 進形式とみなされます。1 ~ 9 の数字で始まる場合は、10 進数形式であるとみなされます。setIntegerBase ()を呼び出すことで、整数の基数を設定して自動検出を無効にすることができます例:

デフォルトでは、QTextStream はテキスト ストリームから数値を読み取るときに、数値の基本表現を自動的に検出します。たとえば、数値が「0x」で始まる場合、その数値は 16 進数形式であるとみなされます。1 ~ 9 の数字で始まる場合は、10 進数形式であるとみなされます。setIntegerBase() を呼び出して整数の基数を設定することで、自動検出を無効にできます。例:

  QTextStream  in("0x50 0x20");

  int 最初の番号、二番目の番号;

  >> の最初の番号; // firstNumber == 80

  >> 10 進数 >> 秒数; // 秒数 == 0

  チャーch;

  >>chで; // ch == 'x'

QTextStream は、テキストを生成するための多くの書式設定オプションをサポートしています。setFieldWidth () およびsetPadChar ()を呼び出すことで、フィールド幅と埋め込み文字を設定できます。setFieldAlignment ()を使用して、各フィールド内の配置を設定します。実数の場合、setRealNumberNotation () およびsetRealNumberPrecision () を呼び出して、生成される数値の表記法 ( SmartNotationScientificNotationFixedNotation ) と桁精度を設定します。いくつかの追加の数値書式設定オプションは、setNumberFlags () を通じて使用することもできます。

QTextStream は、生成されたテキストの多くの書式設定オプションをサポートしています。フィールド幅とパッド文字は、setFieldWidth() および setPadChar() を呼び出すことによって設定できます。setFieldAlignment() を使用して、各フィールドの配置を設定します。実数の場合、setRealNumberNotation() および setRealNumberPrecision() を呼び出して、生成される数値の符号 (SmartNotation、ScientificNotation、FixedNotation) と数値精度を設定します。いくつかの追加の数値形式オプションは、setNumberFlags() を通じて使用することもできます。

標準 C++ ライブラリの <iostream> と同様に、QTextStream もいくつかのグローバル マニピュレータ関数を定義します。

標準 C++ ライブラリの <iostream> と同様、QTextStream もいくつかのグローバル演算子関数を定義します。

マニピュレータ

説明

Qt::bin

setIntegerBase (2)と同じ。

Qt::oct

setIntegerBase (8)と同じです。

Qt::dec

setIntegerBase (10)と同じ。

Qt::hex

setIntegerBase (16)と同じ。

Qt::ショーベース

setNumberFlags ( numberFlags () | ShowBase )と同じです。

Qt::forcesign

setNumberFlags ( numberFlags () | ForceSign )と同じです。

Qt::フォースポイント

setNumberFlags ( numberFlags () | ForcePoint )と同じです。

Qt::noshowbase

setNumberFlags ( numberFlags () & ~ ShowBase )と同じです。

Qt::noforcesign

setNumberFlags ( numberFlags () & ~ ForceSign )と同じです。

Qt::noforcepoint

setNumberFlags ( numberFlags () & ~ ForcePoint )と同じです。

Qt::uppercasebase

setNumberFlags ( numberFlags () | UppercaseBase )と同じです

Qt::大文字の数字

setNumberFlags ( numberFlags () | UppercaseDigits )と同じです

Qt::小文字ベース

setNumberFlags ( numberFlags () & ~ UppercaseBase )と同じです

Qt::小文字

setNumberFlags ( numberFlags () & ~ UppercaseDigits )と同じです

Qt::修正

setRealNumberNotation ( FixedNotation )と同じです

Qt::科学的

setRealNumberNotation ( ScientificNotation )と同じです

Qt::左

setFieldAlignment ( AlignLeft )と同じです

Qt::右

setFieldAlignment ( AlignRight )と同じです

Qt::センター

setFieldAlignment ( AlignCenter )と同じです

Qt::endl

演算子<<('\n') およびフラッシュ()と同じです。

Qt::フラッシュ

フラッシュ()と同じです

Qt::リセット

リセット()と同じです

Qt::ws

SkipWhiteSpace ()と同じ

Qt::良い

setGenerateByteOrderMark (true)と同じ。

さらに、Qt は、パラメーターを取る 3 つのグローバル マニピュレーター、qSetFieldWidth ()、qSetPadChar ()、およびqSetRealNumberPrecision () を提供します。

QDataStream QIODevice QFile QBuffer QTcpSocket、およびText Codecs Exampleも参照してください

QDataStream クラス

QDataStream クラスは、バイナリ データのシリアル化を QIODevice に提供しますもっと...

ヘッダ:

#include <QDataStream>

qmake:

QT += コア

注: このクラスの関数はすべて再入可能です。 

パブリック型

列挙型

ByteOrder  { BigEndian、LittleEndian }

列挙型

FloatingPointPrecision  { SinglePrecision、DoublePrecision }

列挙型

ステータス { OK、ReadPastEnd、ReadCorruptData、WriteFailed }

列挙型

バージョン { Qt_1_0、Qt_2_0、Qt_2_1、Qt_3_0、Qt_3_1、…、Qt_5_14 }

公的行事

QDataStream (const QByteArray &a) )

QDataStream (QByteArray * a、QIODevice::OpenModeモード)

QDataStream (QIODevice * d )

QDataStream ()

~QDataStream ()

空所

トランザクションの中止()

ブール

atEnd () 定数

QDataStream::ByteOrder

byteOrder ()const

ブール

commitTransaction ()

QIOデバイス *

device() const

QDataStream::FloatingPointPrecision

floatingPointPrecision() const

QDataStream &

readBytes(char *&s, uint &l)

int

readRawData(char *s, int len)

void

resetStatus()

void

rollbackTransaction()

void

setByteOrder(QDataStream::ByteOrder bo)

void

setDevice(QIODevice *d)

void

setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision)

void

setStatus(QDataStream::Status status)

void

setVersion(int v)

int

skipRawData(int len)

void

startTransaction()

QDataStream::Status

status() const

int

version() const

QDataStream &

writeBytes(const char *s, uint len)

int

writeRawData(const char *s, int len)

QDataStream &

operator<<(qint8 i)

QDataStream &

operator<<(quint8 i)

QDataStream &

operator<<(qint16 i)

QDataStream &

operator<<(quint16 i)

QDataStream &

operator<<(qint32 i)

QDataStream &

operator<<(quint32 i)

QDataStream &

operator<<(qint64 i)

QDataStream &

operator<<(quint64 i)

QDataStream &

operator<<(std::nullptr_t ptr)

QDataStream &

operator<<(bool i)

QDataStream &

operator<<(qfloat16 f)

QDataStream &

operator<<(float f)

QDataStream &

operator<<(double f)

QDataStream &

operator<<(const char *s)

QDataStream &

operator>>(qint8 &i)

QDataStream &

operator>>(quint8 &i)

QDataStream &

operator>>(qint16 &i)

QDataStream &

operator>>(quint16 &i)

QDataStream &

operator>>(qint32 &i)

QDataStream &

operator>>(quint32 &i)

QDataStream &

operator>>(qint64 &i)

QDataStream &

operator>>(quint64 &i)

QDataStream &

operator>>(std::nullptr_t &ptr)

QDataStream &

operator>>(bool &i)

QDataStream &

operator>>(qfloat16 &f)

QDataStream &

operator>>(float &f)

QDataStream &

operator>>(double &f)

QDataStream &

operator>>(char *&s)

Detailed Description

A data stream is a binary stream of encoded information which is 100% independent of the host computer's operating system, CPU or byte order. For example, a data stream that is written by a PC under Windows can be read by a Sun SPARC running Solaris.

数据流是一种编码信息的二进制流,它100%独立于主机的操作系统、CPU或字节顺序。例如,在Windows下由PC写入的数据流可以由运行Solaris的Sun SPARC读取。

You can also use a data stream to read/write raw unencoded binary data. If you want a "parsing" input stream, see QTextStream.

还可以使用数据流读取/写入原始的未编码二进制数据。如果您想要一个“解析”输入流,请参阅QTextStream。

The QDataStream class implements the serialization of C++'s basic data types, like char, short, int, char *, etc. Serialization of more complex data is accomplished by breaking up the data into primitive units.

QDataStream类实现了C-++的基本数据类型的序列化,如char、短、int、char *等。对更复杂的数据的序列化是通过将数据分解成原始单元来完成的。

A data stream cooperates closely with a QIODevice. A QIODevice represents an input/output medium one can read data from and write data to. The QFile class is an example of an I/O device.

数据流与QIODevice紧密合作。一个QIODevice代表一个可以读取数据和写入数据的输入/输出介质。QFile类是I/O设备的一个例子。

Example (write binary data to a stream):

示例(将二进制数据写入流):

  QFile file("file.dat");

  file.open(QIODevice::WriteOnly);

  QDataStream out(&file);   // we will serialize the data into the file

  out << QString("the answer is");   // serialize a string

  out << (qint32)42;        // serialize an integer

Example (read binary data from a stream):

示例(从流中读取二进制数据)

  QFile file("file.dat");

  file.open(QIODevice::ReadOnly);

  QDataStream in(&file);    // read the data serialized from the file

  QString str;

  qint32 a;

  in >> str >> a;           // extract "the answer is" and 42

Each item written to the stream is written in a predefined binary format that varies depending on the item's type. Supported Qt types include QBrush, QColor, QDateTime, QFont, QPixmap, QString, QVariant and many others. For the complete list of all Qt types supporting data streaming see Serializing Qt Data Types.

写入流的每个项都是用预定义的二进制格式写入的,该格式根据项的类型而不同。支持的Qt类型包括QBrush, QColor, QDateTime, QFont, QPixmap, QString, QVariant和许多其他。有关支持数据流的所有Qt类型的完整列表,请参阅序列化Qt数据类型。

For integers it is best to always cast to a Qt integer type for writing, and to read back into the same Qt integer type. This ensures that you get integers of the size you want and insulates you from compiler and platform differences.

对于整数,最好始终转换为Qt整数类型进行写入,并读回相同的Qt整数类型。这确保您得到您想要的大小的整数,并使您远离编译器和平台的差异

Enumerations can be serialized through QDataStream without the need of manually defining streaming operators. Enum classes are serialized using the declared size.

枚举可以通过QDataStream进行序列化,而不需要手动定义流式操作符。枚举类使用声明的大小进行序列化。

To take one example, a char * string is written as a 32-bit integer equal to the length of the string including the '\0' byte, followed by all the characters of the string including the '\0' byte. When reading a char * string, 4 bytes are read to create the 32-bit length value, then that many characters for the char * string including the '\0' terminator are read.

举个例子,一个char *字符串被写成32位整数,等于包含'\0'字节的字符串长度,后面跟着包含'\0'字节的字符串的所有字符。在读取char *字符串时,将读取4个字节来创建32位的长度值,然后读取包括'\0'终止符在内的char *字符串的许多字符。

The initial I/O device is usually set in the constructor, but can be changed with setDevice(). If you've reached the end of the data (or if there is no I/O device set) atEnd() will return true. 

初始I/O设备通常在构造函数中设置,但可以使用setDevice()进行更改。如果已经到达数据的末尾(或者没有I/O设备设置),atEnd()将返回true。

Versioning

版本控制

QDataStream's binary format has evolved since Qt 1.0, and is likely to continue evolving to reflect changes done in Qt. When inputting or outputting complex types, it's very important to make sure that the same version of the stream (version()) is used for reading and writing. If you need both forward and backward compatibility, you can hardcode the version number in the application:

QDataStream的二进制格式从Qt 1.0开始发展,并且很可能会继续发展,以反映Qt中所做的变化。当输入或输出复杂类型时,确保使用相同版本的流(version())进行读写是非常重要的。如果你需要向前和向后兼容,你可以在应用程序中硬编码版本号:

  stream.setVersion(QDataStream::Qt_4_0);

If you are producing a new binary data format, such as a file format for documents created by your application, you could use a QDataStream to write the data in a portable format. Typically, you would write a brief header containing a magic string and a version number to give yourself room for future expansion. For example:

如果要生成新的二进制数据格式,例如应用程序创建的文档的文件格式,则可以使用QDataStream以可移植格式写入数据。通常,您会编写一个简短的头文件,其中包含一个神奇的字符串和一个版本号,以便为将来的扩展提供空间。例如:

  QFile file("file.xxx");

  file.open(QIODevice::WriteOnly);

  QDataStream out(&file);

  // Write a header with a "magic number" and a version

  out << (quint32)0xA0B0C0D0;

  out << (qint32)123;

  out.setVersion(QDataStream::Qt_4_0);

  // Write the data

  out << lots_of_interesting_data;

Then read it in with:

然后,请阅读以下内容:

  QFile file("file.xxx");

  file.open(QIODevice::ReadOnly);

  QDataStream in(&file);

  // Read and check the header

  quint32 magic;

  in >> magic;

  if (magic != 0xA0B0C0D0)

      return XXX_BAD_FILE_FORMAT;

  // Read the version

  qint32 version;

  in >> version;

  if (version < 100)

      return XXX_BAD_FILE_TOO_OLD;

  if (version > 123)

      return XXX_BAD_FILE_TOO_NEW;

  if (version <= 110)

      in.setVersion(QDataStream::Qt_3_2);

  else

      in.setVersion(QDataStream::Qt_4_0);

  // Read the data

  in >> lots_of_interesting_data;

  if (version >= 120)

      in >> data_new_in_XXX_version_1_2;

  in >> other_interesting_data;

You can select which byte order to use when serializing data. The default setting is big endian (MSB first). Changing it to little endian breaks the portability (unless the reader also changes to little endian). We recommend keeping this setting unless you have special requirements. 

可以选择在序列化数据时使用的字节顺序。默认设置为大端序(MSB优先)。将其更改为小端序会破坏可移植性(除非读取器也更改为小端序)。我们建议保持此设置,除非您有特殊要求。

Reading and Writing Raw Binary Data

读写原始二进制数据

You may wish to read/write your own raw binary data to/from the data stream directly. Data may be read from the stream into a preallocated char * using readRawData(). Similarly data can be written to the stream using writeRawData(). Note that any encoding/decoding of the data must be done by you.

您可能希望直接在数据流中读写自己的原始二进制数据。可以使用readRawData()将数据从流读入预分配的

char *。类似地,可以使用writeRawData()将数据写入流。注意,数据的任何编码/解码都必须由您完成。

A similar pair of functions is readBytes() and writeBytes(). These differ from their raw counterparts as follows: readBytes() reads a quint32 which is taken to be the length of the data to be read, then that number of bytes is read into the preallocated char *; writeBytes() writes a quint32 containing the length of the data, followed by the data. Note that any encoding/decoding of the data (apart from the length quint32) must be done by you. 

类似的一对函数是readBytes()和writeBytes()。它们与原始版本的区别如下:readBytes()读取一个quint32,它被认为是要读取的数据的长度,然后这个字节数被读入预分配的char *;writeBytes()写入一个包含数据长度和后跟数据的quint32。注意,数据的任何编码/解码(长度quint32除外)都必须由您完成。

Reading and Writing Qt Collection Classes

读与写Qt类集合

The Qt container classes can also be serialized to a QDataStream. These include QList, QLinkedList, QVector, QSet, QHash, and QMap. The stream operators are declared as non-members of the classes.

Qt容器类也可以被序列化到QDataStream中。这些包括QList, QLinkedList, QVector, QSet, QHash和QMap。流操作符被声明为类的非成员。 

Reading and Writing Other Qt Classes

读与写Qt其他类

In addition to the overloaded stream operators documented here, any Qt classes that you might want to serialize to a QDataStream will have appropriate stream operators declared as non-member of the class:除了这里记录的重载流操作符,任何你可能想要序列化到QDataStream的Qt类都将有适当的流操作符声明为类的非成员:

      QDataStream &operator<<(QDataStream &, const QXxx &);

      QDataStream &operator>>(QDataStream &, QXxx &);

For example, here are the stream operators declared as non-members of the QImage class:

例如,下面是声明为QImage类的非成员的流操作符:

      QDataStream & operator<< (QDataStream& stream, const QImage& image);

      QDataStream & operator>> (QDataStream& stream, QImage& image);

To see if your favorite Qt class has similar stream operators defined, check the Related Non-Members section of the class's documentation page. 

要查看您最喜欢的Qt类是否定义了类似的流操作符,请检查该类的文档页面中的“Related Non-Members”部分。

Using Read Transactions

使用读取事务

When a data stream operates on an asynchronous device, the chunks of data can arrive at arbitrary points in time. The QDataStream class implements a transaction mechanism that provides the ability to read the data atomically with a series of stream operators. As an example, you can handle incomplete reads from a socket by using a transaction in a slot connected to the readyRead() signal:

当数据流在异步设备上运行时,数据块可以在任意时间点到达。QDataStream类实现了一种事务机制,该机制提供了通过一系列流操作符原子地读取数据的能力。例如,你可以通过使用连接到readyRead()信号的插槽中的事务来处理从套接字的未完成读取:

  in.startTransaction();

  QString str;

  qint32 a;

  in >> str >> a; // try to read packet atomically

  if (!in.commitTransaction())

      return;     // wait for more data

If no full packet is received, this code restores the stream to the initial position, after which you need to wait for more data to arrive.

如果没有收到完整的数据包,这段代码将流恢复到初始位置,之后需要等待更多的数据到达。

See also QTextStream and QVariant.

Member Type Documentation

enum QDataStream::ByteOrder

The byte order used for reading/writing the data.

用于读取/写入数据的字节顺序。

Constant

Value

Description

QDataStream::BigEndian

QSysInfo::BigEndian

Most significant byte first (the default)

QDataStream::LittleEndian

QSysInfo::LittleEndian

Least significant byte first

enum QDataStream::FloatingPointPrecision

The precision of floating point numbers used for reading/writing the data. This will only have an effect if the version of the data stream is Qt_4_6 or higher.

用于读取/写入数据的浮点数的精度。只有当数据流的版本为Qt_4_6或更高时,这才会有效果。

Warning: The floating point precision must be set to the same value on the object that writes and the object that reads the data stream.

警告:在写入数据流的对象和读取数据流的对象上,浮点精度必须设置为相同的值。

Constant

Value

Description

QDataStream::SinglePrecision

0

All floating point numbers in the data stream have 32-bit precision.数据流中的所有浮点数都具有32位精度。

QDataStream::DoublePrecision

1

All floating point numbers in the data stream have 64-bit precision.数据流中的所有浮点数都具有64位精度

See also setFloatingPointPrecision() and floatingPointPrecision().

enum QDataStream::Status

This enum describes the current status of the data stream.

该枚举描述数据流的当前状态。

Constant

Value

Description

QDataStream::Ok

0

The data stream is operating normally.

QDataStream::ReadPastEnd

1

The data stream has read past the end of the data in the underlying device.

QDataStream::ReadCorruptData

2

The data stream has read corrupt data.

QDataStream::WriteFailed

3

The data stream cannot write to the underlying device.

enum QDataStream::Version

This enum provides symbolic synonyms for the data serialization format version numbers.

此枚举为数据序列化格式版本号提供符号同义词。

Constant

Value

Description

QDataStream::Qt_1_0

1

Version 1 (Qt 1.x)

QDataStream::Qt_2_0

2

Version 2 (Qt 2.0)

QDataStream::Qt_2_1

3

Version 3 (Qt 2.1, 2.2, 2.3)

QDataStream::Qt_3_0

4

Version 4 (Qt 3.0)

QDataStream::Qt_3_1

5

Version 5 (Qt 3.1, 3.2)

QDataStream::Qt_3_3

6

Version 6 (Qt 3.3)

QDataStream::Qt_4_0

7

Version 7 (Qt 4.0, Qt 4.1)

QDataStream::Qt_4_1

Qt_4_0

Version 7 (Qt 4.0, Qt 4.1)

QDataStream::Qt_4_2

8

Version 8 (Qt 4.2)

QDataStream::Qt_4_3

9

Version 9 (Qt 4.3)

QDataStream::Qt_4_4

10

Version 10 (Qt 4.4)

QDataStream::Qt_4_5

11

Version 11 (Qt 4.5)

QDataStream::Qt_4_6

12

Version 12 (Qt 4.6, Qt 4.7, Qt 4.8)

QDataStream::Qt_4_7

Qt_4_6

Same as Qt_4_6.

QDataStream::Qt_4_8

Qt_4_7

Same as Qt_4_6.

QDataStream::Qt_4_9

Qt_4_8

Same as Qt_4_6.

QDataStream::Qt_5_0

13

Version 13 (Qt 5.0)

QDataStream::Qt_5_1

14

Version 14 (Qt 5.1)

QDataStream::Qt_5_2

15

Version 15 (Qt 5.2)

QDataStream::Qt_5_3

Qt_5_2

Same as Qt_5_2

QDataStream::Qt_5_4

16

Version 16 (Qt 5.4)

QDataStream::Qt_5_5

Qt_5_4

Same as Qt_5_4

QDataStream::Qt_5_6

17

Version 17 (Qt 5.6)

QDataStream::Qt_5_7

Qt_5_6

Same as Qt_5_6

QDataStream::Qt_5_8

Qt_5_7

Same as Qt_5_6

QDataStream::Qt_5_9

Qt_5_8

Same as Qt_5_6

QDataStream::Qt_5_10

Qt_5_9

Same as Qt_5_6

QDataStream::Qt_5_11

Qt_5_10

Same as Qt_5_6

QDataStream::Qt_5_12

18

Version 18 (Qt 5.12)

QDataStream::Qt_5_13

19

Version 19 (Qt 5.13)

QDataStream::Qt_5_14

Qt_5_13

Same as Qt_5_13

See also setVersion() and version().

本文为出自qt官方文档的翻译

おすすめ

転載: blog.csdn.net/klp1358484518/article/details/127585343