Obsolete Members for QByteArray

以下成员源于类 QByteArray 已过时。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

公共函数

(obsolete) QByteArray & append (const QString & str )
(obsolete) int indexOf (const QString & str , int from = 0) const
(obsolete) QByteArray & insert (int i , const QString & str )
(obsolete) int lastIndexOf (const QString & str , int from = -1) const
(obsolete) QByteArray & replace (const QString & before , const char * after )
(obsolete) QByteArray & replace (char before , const QString & after )
(obsolete) QByteArray & replace (const QString & before , const QByteArray & after )
(obsolete) QByteArray & operator+= (const QString & str )

成员函数文档编制

const char *QByteArray:: operator const char * () const

const void *QByteArray:: operator const void * () const

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

使用 constData () 代替。

Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\0'-terminated. The pointer remains valid as long as the array isn't reallocated or destroyed.

This operator is mostly useful to pass a byte array to a function that accepts a const char * .

可以禁用此运算符通过定义 QT_NO_CAST_FROM_BYTEARRAY when you compile your applications.

注意: QByteArray 可以存储任何字节值 (包括 \0),但大多数函数需要 char * 自变量,假定数据在遇到首个 \0 时结束。

另请参阅 constData ().

QByteArray &QByteArray:: append (const QString & str )

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

追加字符串 str to this byte array. The Unicode data is converted into 8-bit characters using QString::toUtf8 ().

可以禁用此函数通过定义 QT_NO_CAST_TO_ASCII 当编译应用程序时。那么需要调用 QString::toUtf8 () (or QString::toLatin1 () 或 QString::toLocal8Bit ()) explicitly if you want to convert the data to const char * .

int QByteArray:: indexOf (const QString & str , int from = 0) const

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

Returns the index position of the first occurrence of the string str in the byte array, searching forward from index position from . Returns -1 if str could not be found.

The Unicode data is converted into 8-bit characters using QString::toUtf8 ().

可以禁用此函数通过定义 QT_NO_CAST_TO_ASCII 当编译应用程序时。那么需要调用 QString::toUtf8 () (or QString::toLatin1 () 或 QString::toLocal8Bit ()) explicitly if you want to convert the data to const char * .

QByteArray &QByteArray:: insert ( int i , const QString & str )

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

插入字符串 str at index position i in the byte array. The Unicode data is converted into 8-bit characters using QString::toUtf8 ().

i 大于 size (), the array is first extended using resize ().

可以禁用此函数通过定义 QT_NO_CAST_TO_ASCII 当编译应用程序时。那么需要调用 QString::toUtf8 () (or QString::toLatin1 () 或 QString::toLocal8Bit ()) explicitly if you want to convert the data to const char * .

int QByteArray:: lastIndexOf (const QString & str , int from = -1) const

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

Returns the index position of the last occurrence of the string str in the byte array, searching backward from index position from 。若 from is -1 (the default), the search starts at the last ( size () - 1) byte. Returns -1 if str could not be found.

The Unicode data is converted into 8-bit characters using QString::toUtf8 ().

可以禁用此函数通过定义 QT_NO_CAST_TO_ASCII 当编译应用程序时。那么需要调用 QString::toUtf8 () (or QString::toLatin1 () 或 QString::toLocal8Bit ()) explicitly if you want to convert the data to const char * .

QByteArray &QByteArray:: replace (const QString & before , const char * after )

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

Replaces every occurrence of the string before 采用字符串 after .

QByteArray &QByteArray:: replace ( char before , const QString & after )

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

Replaces every occurrence of the character before 采用字符串 after . The Unicode data is converted into 8-bit characters using QString::toUtf8 ().

可以禁用此函数通过定义 QT_NO_CAST_TO_ASCII 当编译应用程序时。那么需要调用 QString::toUtf8 () (or QString::toLatin1 () 或 QString::toLocal8Bit ()) explicitly if you want to convert the data to const char * .

QByteArray &QByteArray:: replace (const QString & before , const QByteArray & after )

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

Replaces every occurrence of the string before with the byte array after . The Unicode data is converted into 8-bit characters using QString::toUtf8 ().

可以禁用此函数通过定义 QT_NO_CAST_TO_ASCII 当编译应用程序时。那么需要调用 QString::toUtf8 () (or QString::toLatin1 () 或 QString::toLocal8Bit ()) explicitly if you want to convert the data to const char * .

QByteArray &QByteArray:: operator+= (const QString & str )

此函数已过时。提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

这是重载函数。

追加字符串 str onto the end of this byte array and returns a reference to this byte array. The Unicode data is converted into 8-bit characters using QString::toUtf8 ().

可以禁用此函数通过定义 QT_NO_CAST_TO_ASCII 当编译应用程序时。那么需要调用 QString::toUtf8 () (or QString::toLatin1 () 或 QString::toLocal8Bit ()) explicitly if you want to convert the data to const char * .