Obsolete Members for QString

以下成員源於類 QString 被棄用。 提供它們是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它們。

公共函數

(deprecated in 6.4) qsizetype count () const
(棄用) QString & setUtf16 (const ushort * unicode , qsizetype size )

靜態公共成員

(deprecated in 6.0) QString fromUcs4 (const uint * str , qsizetype size = -1)
(deprecated in 6.0) QString fromUtf16 (const ushort * str , qsizetype size = -1)

相關非成員

(since 6.2, deprecated in 6.8) QString operator""_qs (const char16_t * str , size_t size )

成員函數文檔編製

[constexpr, deprecated in 6.4] qsizetype QString:: count () const

This function is deprecated since 6.4. We strongly advise against using it in new code.

使用 size () 或 length () 代替。

如同 size ().

This function overloads QString::count().

[static, deprecated in 6.0] QString QString:: fromUcs4 (const uint * str , qsizetype size = -1)

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 char32_t overload instead.

[static, deprecated in 6.0] QString QString:: fromUtf16 (const ushort * str , qsizetype size = -1)

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 char16_t overload instead.

[deprecated] QString &QString:: setUtf16 (const ushort * unicode , qsizetype size )

This function is deprecated. We strongly advise against using it in new code.

使用 char16_t overload instead.

相關非成員

[noexcept, since 6.2, deprecated in 6.8] QString operator""_qs (const char16_t * str , size_t size )

此函數從 6.8 起棄用。強烈建議在新代碼中不要使用它。

使用 _s from Qt::StringLiterals namespace instead.

文字運算符創建的 QString out of the first size characters in the char16_t string literal str .

The QString is created at compile time, and the generated string data is stored in the read-only segment of the compiled object file. Duplicate literals may share the same read-only memory. This functionality is interchangeable with QStringLiteral , but saves typing when many string literals are present in the code.

以下代碼創建 QString :

auto str = u"hello"_qs;
					

該函數在 Qt 6.2 引入。

另請參閱 QStringLiteral and QtLiterals::operator""_qba (const char *str, size_t size).