diff --git a/qmake/generators/xmloutput.cpp b/qmake/generators/xmloutput.cpp index c43f8d810b1..78d6518dabc 100644 --- a/qmake/generators/xmloutput.cpp +++ b/qmake/generators/xmloutput.cpp @@ -103,7 +103,7 @@ void XmlOutput::decreaseIndent() QString XmlOutput::doConversion(const QString &text) { - if (!text.count()) + if (!text.size()) return QString(); else if (conversion == NoConversion) return text; @@ -112,10 +112,10 @@ QString XmlOutput::doConversion(const QString &text) if (conversion == XMLConversion) { // this is a way to escape characters that shouldn't be converted - for (int i=0; i").arg(currentIndent).arg(o.xo_text).arg(o.xo_value)); break; case tCloseTag: - if (o.xo_value.count()) + if (o.xo_value.size()) closeAll(); - else if (o.xo_text.count()) + else if (o.xo_text.size()) closeTo(o.xo_text); else closeTag(); @@ -201,7 +201,7 @@ XmlOutput& XmlOutput::operator<<(const xml_output& o) { // Special case to be able to close tag in normal // way ("", not "/>") without using addRaw().. - if (!o.xo_text.count()) { + if (!o.xo_text.size()) { closeOpen(); break; } @@ -230,14 +230,14 @@ XmlOutput& XmlOutput::operator<<(const xml_output& o) // Output functions ---------------------------------------------------------- void XmlOutput::newTag(const QString &tag) { - Q_ASSERT_X(tag.count(), "XmlOutput", "Cannot open an empty tag"); + Q_ASSERT_X(tag.size(), "XmlOutput", "Cannot open an empty tag"); newTagOpen(tag); closeOpen(); } void XmlOutput::newTagOpen(const QString &tag) { - Q_ASSERT_X(tag.count(), "XmlOutput", "Cannot open an empty tag"); + Q_ASSERT_X(tag.size(), "XmlOutput", "Cannot open an empty tag"); closeOpen(); if (format == NewLine) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 73b98190a71..52d76d689a1 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -112,7 +112,7 @@ int QLoggingRule::pass(QLatin1String cat, QtMsgType msgType) const return (enabled ? 1 : -1); } else if (flags == RightFilter) { // matches right - if (idx == (cat.size() - category.count())) + if (idx == (cat.size() - category.size())) return (enabled ? 1 : -1); } } diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 62c52bbca14..a3254c9a727 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -2659,12 +2659,14 @@ qsizetype QByteArray::count(char ch) const return static_cast(countCharHelper(*this, ch)); } +#if QT_DEPRECATED_SINCE(6, 4) /*! \fn qsizetype QByteArray::count() const - + \deprecated [6.4] Use size() or length() instead. \overload Same as size(). */ +#endif /*! \fn int QByteArray::compare(QByteArrayView bv, Qt::CaseSensitivity cs = Qt::CaseSensitive) const @@ -4481,7 +4483,7 @@ static void q_fromPercentEncoding(QByteArray *ba, char percent) const char *inputPtr = data; qsizetype i = 0; - qsizetype len = ba->count(); + qsizetype len = ba->size(); qsizetype outlen = 0; int a, b; char c; @@ -4584,7 +4586,7 @@ static void q_toPercentEncoding(QByteArray *ba, const char *dontEncode, const ch return; QByteArray input = *ba; - qsizetype len = input.count(); + qsizetype len = input.size(); const char *inputData = input.constData(); char *output = nullptr; qsizetype length = 0; diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index d3b3c3ca6ec..bacc023cdfd 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -468,7 +468,10 @@ public: inline std::string toStdString() const; inline qsizetype size() const noexcept { return d->size; } +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use size() or length() instead.") inline qsizetype count() const noexcept { return size(); } +#endif inline qsizetype length() const noexcept { return size(); } bool isNull() const noexcept; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index c0fed806a6d..1464763b058 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -4671,13 +4671,14 @@ qsizetype QString::count(const QRegularExpression &re) const } #endif // QT_CONFIG(regularexpression) +#if QT_DEPRECATED_SINCE(6, 4) /*! \fn qsizetype QString::count() const - + \deprecated [6.4] Use size() or length() instead. \overload count() Same as size(). */ - +#endif /*! \enum QString::SectionFlag diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 7b494ec2e3b..b30f4ac981b 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -466,7 +466,10 @@ public: QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QString) void swap(QString &other) noexcept { d.swap(other.d); } inline qsizetype size() const { return d.size; } +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use size() or length() instead.") inline qsizetype count() const { return d.size; } +#endif inline qsizetype length() const { return d.size; } inline bool isEmpty() const; void resize(qsizetype size); diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index 554ab0119e1..967f567a6da 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -367,7 +367,7 @@ static void parseCmdLine(QStringList &arguments) if (!arg.startsWith(QLatin1Char('-'))) continue; - char c = arg.count() == 2 ? arg.at(1).toLatin1() : char(0); + char c = arg.size() == 2 ? arg.at(1).toLatin1() : char(0); switch (c) { case 'P': flags |= QDBusConnection::ExportNonScriptableProperties; diff --git a/src/tools/qvkgen/qvkgen.cpp b/src/tools/qvkgen/qvkgen.cpp index 8b59d8880c9..6b0e7520a71 100644 --- a/src/tools/qvkgen/qvkgen.cpp +++ b/src/tools/qvkgen/qvkgen.cpp @@ -586,10 +586,10 @@ bool genVulkanFunctionsPC(const QList &commands, devCmdWrapperStr += "#endif\n\n"; } - if (devCmdNamesStr.count() > 2) - devCmdNamesStr = devCmdNamesStr.left(devCmdNamesStr.count() - 2); - if (instCmdNamesStr.count() > 2) - instCmdNamesStr = instCmdNamesStr.left(instCmdNamesStr.count() - 2); + if (devCmdNamesStr.size() > 2) + devCmdNamesStr.chop(2); + if (instCmdNamesStr.size() > 2) + instCmdNamesStr.chop(2); const QString str = QString::asprintf(s, preamble.get(licHeaderFn).constData(), diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 37b9c90ab40..91611dd0b0f 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -2515,7 +2515,12 @@ void tst_QByteArray::length() QCOMPARE(src.length(), res); QCOMPARE(src.size(), res); +#if QT_DEPRECATED_SINCE(6, 4) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(src.count(), res); +QT_WARNING_POP +#endif } void tst_QByteArray::length_data() diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 32a0374fcd3..921c6d46f24 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -1084,7 +1084,7 @@ void tst_QTextLayout::defaultWordSeparators_data() QString separators(".,:;-<>[](){}=/+%&^*"); separators += QLatin1String("!?"); - for (int i = 0; i < separators.count(); ++i) { + for (int i = 0; i < separators.size(); ++i) { QTest::newRow(QString::number(i).toLatin1().data()) << QString::fromLatin1("abcd") + separators.at(i) + QString::fromLatin1("efgh") << 0 << 4; diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 23c4ed87729..a39e04e58e5 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -2724,8 +2724,8 @@ void tst_QNetworkReply::postToHttpMultipart() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -2812,8 +2812,8 @@ void tst_QNetworkReply::putToHttpMultipart() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -3030,8 +3030,8 @@ void tst_QNetworkReply::postToHttpsMultipart() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -9013,8 +9013,8 @@ void tst_QNetworkReply::ioHttpRedirectMultipartPost() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 OK - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -9179,7 +9179,7 @@ public slots: } if (m_receivedData.length() > 0 && !m_expectedData.startsWith(m_receivedData)) { // We had received some data but it is corrupt! - qDebug() << "CORRUPT" << m_receivedData.count(); + qDebug() << "CORRUPT" << m_receivedData.size(); #if 0 // Use this to track down the pattern of the corruption and conclude the source QFile a("/tmp/corrupt"); diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 5b7b8f312b7..d10396b941a 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -844,9 +844,9 @@ void tst_QSqlQuery::oraClob() QVERIFY_SQL(q, exec(QLatin1String("select bl, cl from %1 where id = 3").arg(clobby))); QVERIFY(q.next()); - QCOMPARE(q.value(0).toString().count(), loong.count()); + QCOMPARE(q.value(0).toString().size(), loong.size()); QVERIFY(q.value(0).toString() == loong); // Deliberately not QCOMPARE() as too long - QCOMPARE(q.value(1).toByteArray().count(), loong.toLatin1().count()); + QCOMPARE(q.value(1).toByteArray().size(), loong.toLatin1().size()); QVERIFY(q.value(1).toByteArray() == loong.toLatin1()); // ditto } @@ -868,7 +868,7 @@ void tst_QSqlQuery::oraClobBatch() QVERIFY_SQL(q, exec("select cl from " + clobBatch)); QVERIFY(q.next()); - QCOMPARE(q.value(0).toString().count(), longString.size()); + QCOMPARE(q.value(0).toString().size(), longString.size()); QVERIFY(q.value(0).toString() == longString); // As above. deliberately not QCOMPARE(). } diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 7f4b431c81f..5a129e78eb2 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1288,9 +1288,9 @@ void tst_Moc::winNewline() QVERIFY(f.open(QIODevice::ReadOnly)); // no QIODevice::Text! QByteArray data = f.readAll(); f.close(); - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { if (data.at(i) == QLatin1Char('\r')) { - QVERIFY(i < data.count() - 1); + QVERIFY(i < data.size() - 1); ++i; QCOMPARE(data.at(i), '\n'); } else { diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 877c61fb645..e1833a37163 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -530,7 +530,7 @@ void tst_QFiledialog::completer() } // press 'keys' for the input - for (int i = 0; i < input.count(); ++i) + for (int i = 0; i < input.size(); ++i) QTest::keyPress(lineEdit, input[i].toLatin1()); QStringList expectedFiles; diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 8261bd85d61..3c6c80a1e3b 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -825,7 +825,7 @@ void tst_QFileDialog2::task203703_returnProperSeparator() QVERIFY(button); QTest::keyClick(button, Qt::Key_Return); QString result = fd.selectedFiles().first(); - QVERIFY(result.at(result.count() - 1) != '/'); + QVERIFY(result.at(result.size() - 1) != '/'); QVERIFY(!result.contains('\\')); current.rmdir("aaaaaaaaaaaaaaaaaa"); } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index b9675b1c0d8..ea0d5e8871f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4019,7 +4019,7 @@ void tst_QWidget::restoreVersion1Geometry() QVERIFY(f.exists()); f.open(QIODevice::ReadOnly); const QByteArray savedGeometry = f.readAll(); - QCOMPARE(savedGeometry.count(), 46); + QCOMPARE(savedGeometry.size(), 46); f.close(); QWidget widget;