diff options
47 files changed, 3 insertions, 1193 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp index 680a099f68..5bcee95d32 100644 --- a/src/corelib/doc/snippets/code/doc_src_containers.cpp +++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp @@ -226,13 +226,6 @@ foreach (const QString &str, map.uniqueKeys()) { //! [20] -//! [21] -forever { - ... -} -//! [21] - - //! [22] CONFIG += no_keywords //! [22] diff --git a/src/corelib/doc/snippets/code/doc_src_qplugin.cpp b/src/corelib/doc/snippets/code/doc_src_qplugin.cpp index 2d6e4a430f..3bca27b966 100644 --- a/src/corelib/doc/snippets/code/doc_src_qplugin.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qplugin.cpp @@ -22,9 +22,3 @@ class MyInstance : public QObject //! [2] Q_IMPORT_PLUGIN(qjpeg) //! [2] - - -//! [3] -TEMPLATE = app -QTPLUGIN += qjpeg qgif # image formats -//! [3] diff --git a/src/corelib/doc/snippets/code/doc_src_qset.cpp b/src/corelib/doc/snippets/code/doc_src_qset.cpp index 64e0b6e450..37f7ced3b0 100644 --- a/src/corelib/doc/snippets/code/doc_src_qset.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qset.cpp @@ -111,23 +111,3 @@ QSet<QString>::const_iterator it = std::find_if(set.cbegin(), set.cend(), predic if (it != set.constEnd()) cout << "Found Jeanette" << endl; //! [12] - - -//! [13] -QSet<QString> set; -set << "red" << "green" << "blue" << ... << "black"; - -QList<QString> list = set.toList(); -std::sort(list.begin(), list.end()); -//! [13] - - -//! [14] -QStringList list; -list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia"; - -QSet<QString> set = QSet<QString>::fromList(list); -set.contains("Julia"); // returns true -set.contains("Mike"); // returns true -set.size(); // returns 2 -//! [14] diff --git a/src/corelib/doc/snippets/code/doc_src_resources.cpp b/src/corelib/doc/snippets/code/doc_src_resources.cpp index 5df085d145..04ecf810ec 100644 --- a/src/corelib/doc/snippets/code/doc_src_resources.cpp +++ b/src/corelib/doc/snippets/code/doc_src_resources.cpp @@ -15,16 +15,3 @@ MyClass::MyClass() : BaseClass() ... } //! [5] - - -//! [6] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(graphlib); - - QFile file(":/graph.png"); - ... - return app.exec(); -} -//! [6] diff --git a/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp b/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp index f8b74cd542..4b77ab607d 100644 --- a/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_animation_qpropertyanimation.cpp @@ -6,7 +6,7 @@ #include <QApplication> #include <QPushButton> #include <QPropertyAnimation> -//! [1] + class MyButtonWidget : public QWidget { public: @@ -31,7 +31,6 @@ int main(int argc, char *argv[]) buttonAnimWidget.show(); return a.exec(); } -//! [1] //! [0] diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index 096e36dc72..70698cd7e0 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -32,17 +32,6 @@ Q_FLAG(Options) typedef QFlags<Enum> Flags; //! [2] - -//! [3] -int myValue = 10; -int minValue = 2; -int maxValue = 6; - -int boundedValue = qBound(minValue, myValue, maxValue); -// boundedValue == 6 -//! [3] - - //! [4] if (!driver()->isOpen() || driver()->isOpenError()) { qWarning("QSqlQuery::exec: database not open"); @@ -61,11 +50,6 @@ quint64 value = Q_UINT64_C(932838457459459); //! [6] -//! [7] -void myMsgHandler(QtMsgType, const char *); -//! [7] - - //! [8] qint64 value = Q_INT64_C(932838457459459); //! [8] @@ -579,11 +563,6 @@ qFuzzyCompare(0.0, 1.0e-200); // This will return false qFuzzyCompare(1 + 0.0, 1 + 1.0e-200); // This will return true //! [46] -//! [47] -CApaApplication *myApplicationFactory(); -//! [47] - - //! [49] void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &); //! [49] @@ -667,19 +646,6 @@ bool readConfiguration(const QFile &file) } //! [qunreachable-switch] -//! [qunreachable-return] - switch (shape) { - case Rectangle: - return rectangle(); - case Triangle: - return triangle(); - case Circle: - return circle(); - case NumShapes: - Q_UNREACHABLE_RETURN(nullptr); - } -//! [qunreachable-return] - //! [qt-version-check] #include <QtGlobal> diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp index 475bc874ec..3a8f7d2747 100644 --- a/src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_io_qfile.cpp @@ -10,16 +10,6 @@ file.open(QIODevice::ReadOnly); // opens "/home/readme.txt" under Unix //! [0] -//! [1] -QByteArray myEncoderFunc(const QString &fileName); -//! [1] - - -//! [2] -QString myDecoderFunc(const QByteArray &localFileName); -//! [2] - - //! [3] #include <stdio.h> diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp index bcc08c0f16..75a04e654f 100644 --- a/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp @@ -84,9 +84,3 @@ out << "Qt rocks!" << Qt::endl; //! [9] stream << '\n' << Qt::flush; //! [9] - - -//! [10] -QTextStream out(&file); -out.setEncoding(QStringConverter::Utf8); -//! [10] diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp index 3f7dc07d9f..4fd7f97ae8 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp @@ -50,16 +50,6 @@ beginMoveRows(parent, 2, 2, parent, 0); beginMoveRows(parent, 2, 2, parent, 4); //! [9] -//! [10] -myData.clear(); -reset(); -//! [10] - -//! [11] -beginResetModel(); -myData.clear(); -endResetModel(); -//! [11] //! [12] class CustomDataProxy : public QSortFilterProxyModel diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp index a213ccbca6..757700786e 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qmetatype.cpp @@ -101,16 +101,6 @@ void someFunc() //! [11] -//! [12] -QPointer<QFile> fp(new QFile); -QVariant var = QVariant::fromValue(fp); -// ... -if (var.canConvert<QObject*>()) { - QObject *sp = var.value<QObject*>(); - qDebug() << sp->metaObject()->className(); // Prints 'QFile'. -} -//! [12] - //! [13] #include <memory> diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index 2c5483abce..1f3789c635 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -129,13 +129,6 @@ void MyObject::timerEvent(QTimerEvent *event) //! [8] -//! [9] -QList<QObject *> list = window()->queryList("QAbstractButton")); -foreach (QObject *obj, list) - static_cast<QAbstractButton *>(obj)->setEnabled(false); -//! [9] - - //! [10] QPushButton *button = parentWidget->findChild<QPushButton *>("button1"); //! [10] @@ -204,22 +197,6 @@ MyWindow::MyWindow() } -//! [18] -int n = messages.count(); -showMessage(tr("%n message(s) saved", "", n)); -//! [18] - - -//! [19] -n == 1 ? tr("%n message saved") : tr("%n messages saved") -//! [19] - - -//! [20] -label->setText(tr("F\374r \310lise")); -//! [20] - - //! [21] if (receivers(SIGNAL(valueChanged(QByteArray))) > 0) { QByteArray data; @@ -383,14 +360,6 @@ public: //! [39] -//! [40] -//: This name refers to a host name. -hostNameLabel->setText(tr("Name:")); - -/*: This text refers to a C++ code example. */ -QString example = tr("Example"); -//! [40] - //! [41] QPushButton *button = parentWidget->findChild<QPushButton *>("button1", Qt::FindDirectChildrenOnly); //! [41] @@ -487,18 +456,6 @@ public: }; //! [52] -//! [meta data] -//: This is a comment for the translator. -//= qtn_foo_bar -//~ loc-layout_id foo_dialog -//~ loc-blank False -//~ magic-stuff This might mean something magic. -QString text = MyMagicClass::tr("Sim sala bim."); -//! [meta data] - -//! [explicit tr context] -QString text = QScrollBar::tr("Page up"); -//! [explicit tr context] //! [53] { diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp index e0c846a587..dcae4b6934 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp @@ -89,11 +89,6 @@ return QVariant::fromValue(s); //! [7] -//! [8] -QObject *object = getObjectFromSomewhere(); -QVariant data = QVariant::fromValue(object); -//! [8] - //! [9] QList<int> intList = {7, 11, 42}; diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qmutexpool.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qmutexpool.cpp deleted file mode 100644 index 1368559b24..0000000000 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qmutexpool.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//! [0] -class Number { -public: - Number(double n) : num (n) { } - - void setNumber(double n) { num = n; } - double number() const { return num; } - -private: - double num; -}; -//! [0] - - -//! [1] -void calcSquare(Number *num) -{ - QMutexLocker locker(mutexpool.get(num)); - num.setNumber(num.number() * num.number()); -} -//! [1] diff --git a/src/corelib/doc/snippets/code/src_corelib_time_qdatetime.cpp b/src/corelib/doc/snippets/code/src_corelib_time_qdatetime.cpp index e86f01a341..588e81bab1 100644 --- a/src/corelib/doc/snippets/code/src_corelib_time_qdatetime.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_time_qdatetime.cpp @@ -71,14 +71,6 @@ QTime::isValid(22, 5, 62); // returns false //! [9] -//! [10] -QTime t; -t.start(); -some_lengthy_task(); -qDebug("Time elapsed: %d ms", t.elapsed()); -//! [10] - - //! [11] QDateTime now = QDateTime::currentDateTime(); QDateTime xmas(QDate(now.date().year(), 12, 25).startOfDay()); diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser.cpp index 6fc3cf5c3c..cc22ba88ce 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qcommandlineparser.cpp @@ -90,12 +90,4 @@ Arguments: //! [3] } -{ -//! [4] -QCommandLineParser parser; -parser.setApplicationDescription(QCoreApplication::translate("main", "The best application in the world")); -parser.addHelpOption(); -//! [4] -} - } diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp index 6a8ca4f742..6edfbd0e28 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp @@ -163,18 +163,6 @@ for (i = hash.begin(); i != hash.end(); ++i) i.value() += 2; //! [18] -void erase() -{ -QHash<QString, int> hash; -//! [20] -QHash<QString, int>::const_iterator i = hash.cbegin(); -while (i != hash.cend()) { - if (i.value() > 10) - i = hash.erase(i); - else - ++i; -} -//! [20] //! [21] erase_if(hash, [](const QHash<QString, int>::iterator it) { return it.value() > 10; }); //! [21] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp index 51d8623cab..462eb28a1e 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp @@ -107,43 +107,6 @@ inline bool operator<(const Employee &e1, const Employee &e2) //! [13] -//! [14] -QMap<QString, int> map; -... -QMap<QString, int>::const_iterator i = map.find("HDR"); -while (i != map.end() && i.key() == "HDR") { - cout << i.value() << Qt::endl; - ++i; -} -//! [14] - - -//! [15] -QMap<int, QString> map; -map.insert(1, "one"); -map.insert(5, "five"); -map.insert(10, "ten"); - -map.lowerBound(0); // returns iterator to (1, "one") -map.lowerBound(1); // returns iterator to (1, "one") -map.lowerBound(2); // returns iterator to (5, "five") -map.lowerBound(10); // returns iterator to (10, "ten") -map.lowerBound(999); // returns end() -//! [15] - - -//! [16] -QMap<QString, int> map; -... -QMap<QString, int>::const_iterator i = map.lowerBound("HDR"); -QMap<QString, int>::const_iterator upperBound = map.upperBound("HDR"); -while (i != upperBound) { - cout << i.value() << Qt::endl; - ++i; -} -//! [16] - - //! [17] QMap<int, QString> map; map.insert(1, "one"); @@ -214,36 +177,6 @@ for (i = map.cbegin(); i != map.cend(); ++i) //! [24] -//! [25] -QMultiMap<QString, int> map1, map2, map3; - -map1.insert("plenty", 100); -map1.insert("plenty", 2000); -// map1.size() == 2 - -map2.insert("plenty", 5000); -// map2.size() == 1 - -map3 = map1 + map2; -// map3.size() == 3 -//! [25] - - -//! [26] -QList<int> values = map.values("plenty"); -for (int i = 0; i < values.size(); ++i) - cout << values.at(i) << Qt::endl; -//! [26] - - -//! [27] -QMultiMap<QString, int>::iterator i = map.find("plenty"); -while (i != map.end() && i.key() == "plenty") { - cout << i.value() << Qt::endl; - ++i; -} -//! [27] - //! [keyiterator1] for (QMap<int, QString>::const_iterator it = map.cbegin(), end = map.cend(); it != end; ++it) { cout << "The key: " << it.key() << Qt::endl diff --git a/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp b/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp deleted file mode 100644 index 0b307c33c4..0000000000 --- a/src/corelib/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//! [0] -int ret = QMessageBox::warning(this, tr("My Application"), - tr("The document has been modified.\n" - "Do you want to save your changes?"), - QMessageBox::Save | QMessageBox::Discard - | QMessageBox::Cancel, - QMessageBox::Save); -//! [0] - - -//! [1] -QMessageBox msgBox; -msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); -switch (msgBox.exec()) { -case QMessageBox::Yes: - // yes was clicked - break; -case QMessageBox::No: - // no was clicked - break; -default: - // should never be reached - break; -} -//! [1] - - -//! [2] -QMessageBox msgBox; -QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole); -QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort); - -msgBox.exec(); - -if (msgBox.clickedButton() == connectButton) { - // connect -} else if (msgBox.clickedButton() == abortButton) { - // abort -} -//! [2] - - -//! [3] -QMessageBox messageBox(this); -QAbstractButton *disconnectButton = - messageBox.addButton(tr("Disconnect"), QMessageBox::ActionRole); -... -messageBox.exec(); -if (messageBox.clickedButton() == disconnectButton) { - ... -} -//! [3] - - -//! [4] -#include <QApplication> -#include <QMessageBox> - -int main(int argc, char *argv[]) -{ - QT_REQUIRE_VERSION(argc, argv, "6.1.2") - - QApplication app(argc, argv); - ... - return app.exec(); -} -//! [4] - -//! [5] -QMessageBox msgBox; -msgBox.setText("The document has been modified."); -msgBox.exec(); -//! [5] - -//! [6] -QMessageBox msgBox; -msgBox.setText("Do you want to save your changes?"); -msgBox.setInformativeText("The document has been modified. It was last saved 5 days ago."); -msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); -msgBox.setDefaultButton(QMessageBox::Save); -int ret = msgBox.exec(); -//! [6] - -//! [7] -switch (ret) { - case QMessageBox::Save: - // Save was clicked - break; - case QMessageBox::Discard: - // Don't Save was clicked - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; -} -//! [7] - -//! [9] -QMessageBox msgBox(this); -msgBox.setText(tr("The document has been modified.\n" - "Do you want to save your changes?")); -msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard - | QMessageBox::Cancel); -msgBox.setDefaultButton(QMessageBox::Save); -//! [9] diff --git a/src/corelib/doc/snippets/jni/src_qjniobject.cpp b/src/corelib/doc/snippets/jni/src_qjniobject.cpp index ca402fa3d7..6e66b51383 100644 --- a/src/corelib/doc/snippets/jni/src_qjniobject.cpp +++ b/src/corelib/doc/snippets/jni/src_qjniobject.cpp @@ -1,23 +1,6 @@ // Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -//! [Working with lists] -QStringList getTrackTitles(const QJniObject &album) { - QStringList stringList; - QJniObject list = album.callObjectMethod("getTitles", - "()Ljava/util/List;"); - - if (list.isValid()) { - const int size = list.callMethod<jint>("size"); - for (int i = 0; i < size; ++i) { - QJniObject title = list.callObjectMethod("get", "(I)Ljava/lang/Object;", i); - stringList.append(title.toString()); - } - } - return stringList; -} -//! [Working with lists] - //! [QJniObject scope] void functionScope() { diff --git a/src/corelib/doc/snippets/qstring/stringbuilder.cpp b/src/corelib/doc/snippets/qstring/stringbuilder.cpp index 61b7a9a133..a48f9858b3 100644 --- a/src/corelib/doc/snippets/qstring/stringbuilder.cpp +++ b/src/corelib/doc/snippets/qstring/stringbuilder.cpp @@ -15,10 +15,6 @@ using namespace Qt::StringLiterals; ... //! [0] -//! [3] - DEFINES *= QT_USE_QSTRINGBUILDER -//! [3] - //! [5] #include <QStringBuilder> diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp index 92456c35c4..de98aa56ec 100644 --- a/src/corelib/doc/snippets/resource-system/mainwindow.cpp +++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp @@ -1,15 +1,10 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -//! [0] #include <QtWidgets> #include "mainwindow.h" -//! [0] - -//! [1] MainWindow::MainWindow() -//! [1] //! [2] { textEdit = new QPlainTextEdit; setCentralWidget(textEdit); @@ -27,11 +22,8 @@ MainWindow::MainWindow() setCurrentFile(QString()); setUnifiedTitleAndToolBarOnMac(true); } -//! [2] -//! [3] void MainWindow::closeEvent(QCloseEvent *event) -//! [3] //! [4] { if (maybeSave()) { writeSettings(); @@ -40,22 +32,16 @@ void MainWindow::closeEvent(QCloseEvent *event) event->ignore(); } } -//! [4] -//! [5] void MainWindow::newFile() -//! [5] //! [6] { if (maybeSave()) { textEdit->clear(); setCurrentFile(QString()); } } -//! [6] -//! [7] void MainWindow::open() -//! [7] //! [8] { if (maybeSave()) { QString fileName = QFileDialog::getOpenFileName(this); @@ -63,11 +49,8 @@ void MainWindow::open() loadFile(fileName); } } -//! [8] -//! [9] bool MainWindow::save() -//! [9] //! [10] { if (curFile.isEmpty()) { return saveAs(); @@ -75,11 +58,8 @@ bool MainWindow::save() return saveFile(curFile); } } -//! [10] -//! [11] bool MainWindow::saveAs() -//! [11] //! [12] { QString fileName = QFileDialog::getSaveFileName(this); if (fileName.isEmpty()) @@ -87,42 +67,31 @@ bool MainWindow::saveAs() return saveFile(fileName); } -//! [12] -//! [13] void MainWindow::about() -//! [13] //! [14] { QMessageBox::about(this, tr("About Application"), tr("The <b>Application</b> example demonstrates how to " "write modern GUI applications using Qt, with a menu bar, " "toolbars, and a status bar.")); } -//! [14] -//! [15] void MainWindow::documentWasModified() -//! [15] //! [16] { setWindowModified(textEdit->document()->isModified()); } -//! [16] -//! [17] void MainWindow::createActions() -//! [17] //! [18] { newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); newAct->setShortcuts(QKeySequence::New); newAct->setStatusTip(tr("Create a new file")); connect(newAct, &QAction::triggered, this, &MainWindow::newFile); -//! [19] openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing file")); connect(openAct, &QAction::triggered, this, &MainWindow::open); -//! [18] //! [19] saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); saveAct->setShortcuts(QKeySequence::Save); @@ -134,10 +103,8 @@ void MainWindow::createActions() saveAsAct->setStatusTip(tr("Save the document under a new name")); connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs); -//! [20] exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); -//! [20] exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, &QAction::triggered, this, &MainWindow::close); @@ -165,34 +132,24 @@ void MainWindow::createActions() aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, &QAction::triggered, this, &MainWindow::about); -//! [22] aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt); -//! [22] -//! [23] cutAct->setEnabled(false); -//! [23] //! [24] copyAct->setEnabled(false); connect(textEdit, &QTextEdit::copyAvailable, cutAct, &QAction::setEnabled); connect(textEdit, &QTextEdit::copyAvailable, copyAct, &QAction::setEnabled); } -//! [24] -//! [25] //! [26] void MainWindow::createMenus() -//! [25] //! [27] { fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(newAct); -//! [28] fileMenu->addAction(openAct); -//! [28] fileMenu->addAction(saveAct); -//! [26] fileMenu->addAction(saveAsAct); fileMenu->addSeparator(); fileMenu->addAction(exitAct); @@ -208,16 +165,12 @@ void MainWindow::createMenus() helpMenu->addAction(aboutAct); helpMenu->addAction(aboutQtAct); } -//! [27] -//! [29] //! [30] void MainWindow::createToolBars() { fileToolBar = addToolBar(tr("File")); fileToolBar->addAction(newAct); -//! [29] //! [31] fileToolBar->addAction(openAct); -//! [31] fileToolBar->addAction(saveAct); editToolBar = addToolBar(tr("Edit")); @@ -225,19 +178,13 @@ void MainWindow::createToolBars() editToolBar->addAction(copyAct); editToolBar->addAction(pasteAct); } -//! [30] -//! [32] void MainWindow::createStatusBar() -//! [32] //! [33] { statusBar()->showMessage(tr("Ready")); } -//! [33] -//! [34] //! [35] void MainWindow::readSettings() -//! [34] //! [36] { QSettings settings("QtProject", "Application Example"); QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); @@ -245,21 +192,15 @@ void MainWindow::readSettings() resize(size); move(pos); } -//! [35] //! [36] -//! [37] //! [38] void MainWindow::writeSettings() -//! [37] //! [39] { QSettings settings("QtProject", "Application Example"); settings.setValue("pos", pos()); settings.setValue("size", size()); } -//! [38] //! [39] -//! [40] bool MainWindow::maybeSave() -//! [40] //! [41] { if (textEdit->document()->isModified()) { QMessageBox::StandardButton ret; @@ -274,11 +215,8 @@ bool MainWindow::maybeSave() } return true; } -//! [41] -//! [42] void MainWindow::loadFile(const QString &fileName) -//! [42] //! [43] { QFile file(fileName); if (!file.open(QFile::ReadOnly | QFile::Text)) { @@ -301,11 +239,8 @@ void MainWindow::loadFile(const QString &fileName) setCurrentFile(fileName); statusBar()->showMessage(tr("File loaded"), 2000); } -//! [43] -//! [44] bool MainWindow::saveFile(const QString &fileName) -//! [44] //! [45] { QFile file(fileName); if (!file.open(QFile::WriteOnly | QFile::Text)) { @@ -329,11 +264,8 @@ bool MainWindow::saveFile(const QString &fileName) statusBar()->showMessage(tr("File saved"), 2000); return true; } -//! [45] -//! [46] void MainWindow::setCurrentFile(const QString &fileName) -//! [46] //! [47] { curFile = fileName; textEdit->document()->setModified(false); @@ -344,12 +276,8 @@ void MainWindow::setCurrentFile(const QString &fileName) shownName = "untitled.txt"; setWindowFilePath(shownName); } -//! [47] -//! [48] QString MainWindow::strippedName(const QString &fullFileName) -//! [48] //! [49] { return QFileInfo(fullFileName).fileName(); } -//! [49] diff --git a/src/corelib/doc/snippets/threads/threads.cpp b/src/corelib/doc/snippets/threads/threads.cpp index 57c68cd358..502bc4bfe0 100644 --- a/src/corelib/doc/snippets/threads/threads.cpp +++ b/src/corelib/doc/snippets/threads/threads.cpp @@ -7,9 +7,7 @@ #define Counter ReentrantCounter -//! [3] class Counter -//! [3] //! [4] { public: Counter() { n = 0; } @@ -21,14 +19,11 @@ public: private: int n; }; -//! [4] #undef Counter #define Counter ThreadSafeCounter -//! [5] class Counter -//! [5] //! [6] { public: Counter() { n = 0; } @@ -41,7 +36,6 @@ private: mutable QMutex mutex; int n; }; -//! [6] typedef int SomeClass; diff --git a/src/corelib/doc/snippets/timers/analogclock.cpp b/src/corelib/doc/snippets/timers/analogclock.cpp index 4052c185c4..0e910f405b 100644 --- a/src/corelib/doc/snippets/timers/analogclock.cpp +++ b/src/corelib/doc/snippets/timers/analogclock.cpp @@ -5,7 +5,7 @@ #include "analogclock.h" -//! [0] //! [1] +//! [0] AnalogClock::AnalogClock(QWidget *parent) //! [0] //! [2] : QWidget(parent) @@ -23,11 +23,9 @@ AnalogClock::AnalogClock(QWidget *parent) resize(200, 200); //! [7] } -//! [1] //! [7] +//! [7] -//! [8] //! [9] void AnalogClock::paintEvent(QPaintEvent *) -//! [8] //! [10] { static const QPoint hourHand[3] = { QPoint(7, 8), @@ -45,64 +43,40 @@ void AnalogClock::paintEvent(QPaintEvent *) int side = qMin(width(), height()); QTime time = QTime::currentTime(); -//! [10] -//! [11] QPainter painter(this); -//! [11] //! [12] painter.setRenderHint(QPainter::Antialiasing); -//! [12] //! [13] painter.translate(width() / 2, height() / 2); -//! [13] //! [14] painter.scale(side / 200.0, side / 200.0); -//! [9] //! [14] -//! [15] painter.setPen(Qt::NoPen); -//! [15] //! [16] painter.setBrush(hourColor); -//! [16] -//! [17] //! [18] painter.save(); -//! [17] //! [19] painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); painter.drawConvexPolygon(hourHand, 3); painter.restore(); -//! [18] //! [19] -//! [20] painter.setPen(hourColor); -//! [20] //! [21] for (int i = 0; i < 12; ++i) { painter.drawLine(88, 0, 96, 0); painter.rotate(30.0); } -//! [21] -//! [22] painter.setPen(Qt::NoPen); -//! [22] //! [23] painter.setBrush(minuteColor); -//! [24] painter.save(); painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); painter.drawConvexPolygon(minuteHand, 3); painter.restore(); -//! [23] //! [24] -//! [25] painter.setPen(minuteColor); -//! [25] //! [26] -//! [27] for (int j = 0; j < 60; ++j) { if ((j % 5) != 0) painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } -//! [27] } -//! [26] diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp index ab8521b465..9455cacf1c 100644 --- a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp +++ b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp @@ -19,70 +19,6 @@ struct MyWidget int manhattanLength() { return 0; } }; - -//! [0] -QCoreApplication *createApplication(int &argc, char *argv[]) -{ - for (int i = 1; i < argc; ++i) - if (!qstrcmp(argv[i], "-no-gui")) - return new QCoreApplication(argc, argv); - return new QApplication(argc, argv); -} - -int main(int argc, char *argv[]) -{ - QScopedPointer<QCoreApplication> app(createApplication(argc, argv)); - - if (qobject_cast<QApplication *>(app.data())) { - // start GUI version... - } else { - // start non-GUI version... - } - - return app->exec(); -} -//! [0] - - -void wrapper0() { - -//! [1] -QApplication::setStyle(QStyleFactory::create("fusion")); -//! [1] - -} // wrapper0 - - -//! [3] -QSize MyWidget::sizeHint() const -{ - return QSize(80, 25); -} -//! [3] - - -//! [4] -void showAllHiddenTopLevelWidgets() -{ - const auto topLevelWidgets = QApplication::topLevelWidgets(); - for (QWidget *widget : topLevelWidgets) { - if (widget->isHidden()) - widget->show(); - } -} -//! [4] - - -//! [5] -void updateAllWidgets() -{ - const auto topLevelWidgets = QApplication::topLevelWidgets(); - for (QWidget *widget : topLevelWidgets) - widget->update(); -} -//! [5] - - void startTheDrag() {}; void wrapper1() { MyWidget startPos; @@ -96,25 +32,6 @@ if ((startPos - currentPos).manhattanLength() >= startTheDrag(); //! [6] - -//! [7] -QWidget *widget = qApp->widgetAt(x, y); -if (widget) - widget = widget->window(); -//! [7] - } // wrapper1 - -void wrapper2() { -QPoint point; - -//! [8] -QWidget *widget = qApp->widgetAt(point); -if (widget) - widget = widget->window(); -//! [8] - - -} // wrapper2 } // src_gui_kernel_qapplication diff --git a/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp index 17436c9de5..97e5da1960 100644 --- a/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp +++ b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp @@ -97,15 +97,6 @@ struct QPainter { void setWorldTransform(QTransform matrix, bool); }; -//! [4] -void QPainter::rotate(qreal angle) -{ - QTransform matrix; - matrix.rotate(angle); - setWorldTransform(matrix, true); -} -//! [4] - } // QPainterWrapper void MyWidget::wrapper1() { diff --git a/src/gui/doc/snippets/code/src_gui_text_qtextdocument.cpp b/src/gui/doc/snippets/code/src_gui_text_qtextdocument.cpp deleted file mode 100644 index 570728f41d..0000000000 --- a/src/gui/doc/snippets/code/src_gui_text_qtextdocument.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -namespace src_gui_text_qtextdocument { - -/* wrap non-code snippet - -//! [0] -<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>... -//! [0] - -*/ // wrap non-code snippet -} // src_gui_text_qtextdocument diff --git a/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp b/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp index 96c8040eb2..13deb88bc8 100644 --- a/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp +++ b/src/gui/doc/snippets/code/src_gui_util_qdesktopservices.cpp @@ -65,15 +65,6 @@ QDesktopServices::openUrl(QUrl("file:///C:/Program Files", QUrl::TolerantMode)); */ // comment wrapper 2 - -void wrapper3() { -//! [6] -QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + - "/data/organization/application"; -//! [6] -} // wrapper3 - - /* comment wrapper 3 //! [7] <key>com.apple.developer.associated-domains</key> diff --git a/src/gui/doc/snippets/image/image.cpp b/src/gui/doc/snippets/image/image.cpp index b1c42d62da..82703c5c0f 100644 --- a/src/gui/doc/snippets/image/image.cpp +++ b/src/gui/doc/snippets/image/image.cpp @@ -25,13 +25,6 @@ buffer.open(QIODevice::WriteOnly); pixmap.save(&buffer, "PNG"); // writes pixmap into bytes in PNG format //! [1] - -//! [2] -QPixmap alpha("image-with-alpha.png"); -QPixmap alphacopy = alpha; -alphacopy.setMask(alphacopy.mask()); -//! [2] - } // wrapper1 } // image diff --git a/src/network/doc/snippets/code/doc_src_qtnetwork.cpp b/src/network/doc/snippets/code/doc_src_qtnetwork.cpp deleted file mode 100644 index dae56d5db5..0000000000 --- a/src/network/doc/snippets/code/doc_src_qtnetwork.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//! [1] -#include <QtNetwork> -//! [1] diff --git a/src/network/doc/snippets/code/src_network_ssl_qsslsocket.cpp b/src/network/doc/snippets/code/src_network_ssl_qsslsocket.cpp index 89d82d66f8..eed032589e 100644 --- a/src/network/doc/snippets/code/src_network_ssl_qsslsocket.cpp +++ b/src/network/doc/snippets/code/src_network_ssl_qsslsocket.cpp @@ -49,12 +49,6 @@ socket->write("1 CAPABILITY\r\n"); //! [3] -//! [4] -QSslSocket socket; -socket.setCiphers("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA"); -//! [4] - - //! [5] socket->connectToHostEncrypted("imap", 993); if (socket->waitForEncrypted(1000)) diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp index 92c1281aa9..efcb45c98e 100644 --- a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp +++ b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp @@ -47,10 +47,8 @@ if (q.next()) //! [26] qDebug( \ -//! [31] "QSqlDatabase: QMYSQL driver not loaded \ QSqlDatabase: available drivers: QMYSQL" \ -//! [31] ); /* Commented because the following line is not compilable diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp index e81436a247..48382bfee9 100644 --- a/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp +++ b/src/sql/doc/snippets/sqldatabase/sqldatabase_snippet.cpp @@ -17,17 +17,13 @@ //! [20] } -//! [21] QSqlQueryModel model; model.setQuery("SELECT name, salary FROM employee"); int salary = model.record(4).value("salary").toInt(); -//! [21] Q_UNUSED(salary); { -//! [22] int salary = model.data(model.index(4, 1)).toInt(); -//! [22] Q_UNUSED(salary); } @@ -47,7 +43,6 @@ public: int m_specialColumnNo; }; -//! [23] QVariant MyModel::data(const QModelIndex &item, int role) const { if (item.column() == m_specialColumnNo) { @@ -55,7 +50,6 @@ QVariant MyModel::data(const QModelIndex &item, int role) const } return QSqlQueryModel::data(item, role); } -//! [23] void QSqlTableModel_snippets() { @@ -72,258 +66,8 @@ void QSqlTableModel_snippets() view->hideColumn(0); // don't show the ID view->show(); //! [24] - - { -//! [25] - QSqlTableModel model; - model.setTable("employee"); - model.select(); - int salary = model.record(4).value("salary").toInt(); -//! [25] - } -} - -void sql_intro_snippets() -{ - { -//! [26] - QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); - db.setHostName("bigblue"); - db.setDatabaseName("flightdb"); - db.setUserName("acarlson"); - db.setPassword("1uTbSbAs"); - bool ok = db.open(); -//! [26] - Q_UNUSED(ok); - } - - { -//! [27] - QSqlDatabase firstDB = QSqlDatabase::addDatabase("QMYSQL", "first"); - QSqlDatabase secondDB = QSqlDatabase::addDatabase("QMYSQL", "second"); -//! [27] - } - - { -//! [28] - QSqlDatabase defaultDB = QSqlDatabase::database(); -//! [28] //! [29] - QSqlDatabase firstDB = QSqlDatabase::database("first"); -//! [29] //! [30] - QSqlDatabase secondDB = QSqlDatabase::database("second"); -//! [30] - } - - { - // SELECT1 -//! [31] - QSqlQuery query; - query.exec("SELECT name, salary FROM employee WHERE salary > 50000"); -//! [31] - -//! [32] - while (query.next()) { - QString name = query.value(0).toString(); - int salary = query.value(1).toInt(); - qDebug() << name << salary; - } -//! [32] - } - - { - // FEATURE -//! [33] - QSqlQuery query; - int numRows; - query.exec("SELECT name, salary FROM employee WHERE salary > 50000"); - - QSqlDatabase defaultDB = QSqlDatabase::database(); - if (defaultDB.driver()->hasFeature(QSqlDriver::QuerySize)) { - numRows = query.size(); - } else { - // this can be very slow - query.last(); - numRows = query.at() + 1; - } -//! [33] - } - - { - // INSERT1 -//! [34] - QSqlQuery query; - query.exec("INSERT INTO employee (id, name, salary) " - "VALUES (1001, 'Thad Beaumont', 65000)"); -//! [34] - } - - { - // NAMED BINDING -//! [35] - QSqlQuery query; - query.prepare("INSERT INTO employee (id, name, salary) " - "VALUES (:id, :name, :salary)"); - query.bindValue(":id", 1001); - query.bindValue(":name", "Thad Beaumont"); - query.bindValue(":salary", 65000); - query.exec(); -//! [35] - } - - { - // POSITIONAL BINDING -//! [36] - QSqlQuery query; - query.prepare("INSERT INTO employee (id, name, salary) " - "VALUES (?, ?, ?)"); - query.addBindValue(1001); - query.addBindValue("Thad Beaumont"); - query.addBindValue(65000); - query.exec(); -//! [36] - } - - { - // UPDATE1 -//! [37] - QSqlQuery query; - query.exec("UPDATE employee SET salary = 70000 WHERE id = 1003"); -//! [37] - } - - { - // DELETE1 -//! [38] - QSqlQuery query; - query.exec("DELETE FROM employee WHERE id = 1007"); -//! [38] - } - - { - // TRANSACTION -//! [39] - QSqlDatabase::database().transaction(); - QSqlQuery query; - query.exec("SELECT id FROM employee WHERE name = 'Torild Halvorsen'"); - if (query.next()) { - int employeeId = query.value(0).toInt(); - query.exec("INSERT INTO project (id, name, ownerid) " - "VALUES (201, 'Manhattan Project', " - + QString::number(employeeId) + ')'); - } - QSqlDatabase::database().commit(); -//! [39] - } - - { - // SQLQUERYMODEL1 -//! [40] - QSqlQueryModel model; - model.setQuery("SELECT * FROM employee"); - - for (int i = 0; i < model.rowCount(); ++i) { - int id = model.record(i).value("id").toInt(); - QString name = model.record(i).value("name").toString(); - qDebug() << id << name; - } -//! [40] - } - - { - // SQLTABLEMODEL1 -//! [41] - QSqlTableModel model; - model.setTable("employee"); - model.setFilter("salary > 50000"); - model.setSort(2, Qt::DescendingOrder); - model.select(); - - for (int i = 0; i < model.rowCount(); ++i) { - QString name = model.record(i).value("name").toString(); - int salary = model.record(i).value("salary").toInt(); - qDebug() << name << salary; - } -//! [41] - } - - { - // SQLTABLEMODEL2 - QSqlTableModel model; - model.setTable("employee"); - -//! [42] - for (int i = 0; i < model.rowCount(); ++i) { - QSqlRecord record = model.record(i); - double salary = record.value("salary").toInt(); - salary *= 1.1; - record.setValue("salary", salary); - model.setRecord(i, record); - } - model.submitAll(); -//! [42] - - // SQLTABLEMODEL3 - int row = 1; - int column = 2; -//! [43] - model.setData(model.index(row, column), 75000); - model.submitAll(); -//! [43] - - // SQLTABLEMODEL4 -//! [44] - model.insertRows(row, 1); - model.setData(model.index(row, 0), 1013); - model.setData(model.index(row, 1), "Peter Gordon"); - model.setData(model.index(row, 2), 68500); - model.submitAll(); -//! [44] - -//! [45] - model.removeRows(row, 5); -//! [45] //! [46] - model.submitAll(); -//! [46] - } } -//! [47] -class XyzResult : public QSqlResult -{ -public: - XyzResult(const QSqlDriver *driver) - : QSqlResult(driver) {} - ~XyzResult() {} - -protected: - QVariant data(int /* index */) override { return QVariant(); } - bool isNull(int /* index */) override { return false; } - bool reset(const QString & /* query */) override { return false; } - bool fetch(int /* index */) override { return false; } - bool fetchFirst() override { return false; } - bool fetchLast() override { return false; } - int size() override { return 0; } - int numRowsAffected() override { return 0; } - QSqlRecord record() const override { return QSqlRecord(); } -}; -//! [47] - -//! [48] -class XyzDriver : public QSqlDriver -{ -public: - XyzDriver() {} - ~XyzDriver() {} - - bool hasFeature(DriverFeature /* feature */) const override { return false; } - bool open(const QString & /* db */, const QString & /* user */, - const QString & /* password */, const QString & /* host */, - int /* port */, const QString & /* options */) override - { return false; } - void close() {} - QSqlResult *createResult() const override { return new XyzResult(this); } -}; -//! [48] int main(int argc, char **argv) { diff --git a/src/testlib/doc/snippets/code/CMakeLists.txt b/src/testlib/doc/snippets/code/CMakeLists.txt index 86057acde2..0905a15695 100644 --- a/src/testlib/doc/snippets/code/CMakeLists.txt +++ b/src/testlib/doc/snippets/code/CMakeLists.txt @@ -3,7 +3,6 @@ add_library(testlib_code_snippets OBJECT doc_src_qtqskip.cpp - doc_src_qttest.cpp src_corelib_kernel_qtestsupport_core.cpp ) diff --git a/src/testlib/doc/snippets/code/doc_src_qsignalspy.cpp b/src/testlib/doc/snippets/code/doc_src_qsignalspy.cpp index 20459f9eb4..99760ea730 100644 --- a/src/testlib/doc/snippets/code/doc_src_qsignalspy.cpp +++ b/src/testlib/doc/snippets/code/doc_src_qsignalspy.cpp @@ -43,9 +43,6 @@ SomeStruct result = qvariant_cast<SomeStruct>(spy.at(0).at(0)); QSignalSpy spy(myPushButton, SIGNAL(clicked(bool))); //! [4] -//! [5] -QVERIFY(spy.wait(1000)); -//! [5] //! [6] QSignalSpy spy(myPushButton, &QPushButton::clicked); diff --git a/src/testlib/doc/snippets/code/doc_src_qttest.cpp b/src/testlib/doc/snippets/code/doc_src_qttest.cpp deleted file mode 100644 index 06b4588268..0000000000 --- a/src/testlib/doc/snippets/code/doc_src_qttest.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//! [0] -#include <QTest> -//! [0] diff --git a/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp b/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp index 7ac3577648..2c8a892511 100644 --- a/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp +++ b/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp @@ -26,48 +26,3 @@ setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); QWidget *centralWidget = new QWidget(this); setCentralWidget(centralWidget); //! [3] - - -//! [4] -QPopupMenu *fileMenu = new QPopupMenu(this); -openAction->addTo(fileMenu); -saveAction->addTo(fileMenu); -... -menuBar()->insertItem(tr("&File"), fileMenu); -//! [4] - - -//! [5] -QMenu *fileMenu = menuBar()->addMenu(tr("&File")); -fileMenu->addAction(openAction); -fileMenu->addAction(saveAction); -... -//! [5] - - -//! [6] -QToolBar *fileTools = new QToolBar(this, "file toolbar"); -openAction->addTo(fileTools); -saveAction->addTo(fileTools); -... -//! [6] - - -//! [7] -QToolBar *fileTools = addToolBar(tr("File Tool Bar")); -fileTools->addAction(openAction); -fileTools->addAction(saveAction); -... -//! [7] - - -//! [8] -QDockWidget *dockWidget = new QDockWidget(this); -mainWin->moveDockWidget(dockWidget, Qt::DockLeft); -//! [8] - - -//! [9] -QDockWidget *dockWidget = new QDockWidget(mainWindow); -mainWindow->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); -//! [9] diff --git a/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp b/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp index 3620c261a5..2ec3afba01 100644 --- a/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp +++ b/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp @@ -24,22 +24,3 @@ void MyWidget::paintEvent(QPaintEvent *event) this); } //! [1] - - -//! [2] -void drawControl(ControlElement element, - QPainter *painter, - const QWidget *widget, - const QRect &rect, - const QColorGroup &colorGroup, - SFlags how = Style_Default, - const QStyleOption &option = QStyleOption::Default) const; -//! [2] - - -//! [3] -void drawControl(ControlElement element, - const QStyleOption *option, - QPainter *painter, - const QWidget *widget = nullptr) const; -//! [3] diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp index 014a9dfeb0..ebc07025ec 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp @@ -11,23 +11,6 @@ int ret = QMessageBox::warning(this, tr("My Application"), //! [0] -//! [1] -QMessageBox msgBox; -msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); -switch (msgBox.exec()) { -case QMessageBox::Yes: - // yes was clicked - break; -case QMessageBox::No: - // no was clicked - break; -default: - // should never be reached - break; -} -//! [1] - - //! [2] QMessageBox msgBox; QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole); @@ -100,12 +83,3 @@ switch (ret) { break; } //! [7] - -//! [9] -QMessageBox msgBox(this); -msgBox.setText(tr("The document has been modified.\n" - "Do you want to save your changes?")); -msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard - | QMessageBox::Cancel); -msgBox.setDefaultButton(QMessageBox::Save); -//! [9] diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp index e9e8b95847..bcf675d8af 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp @@ -71,24 +71,6 @@ rect.deviceTransform(view->viewportTransform()).inverted().map(QPointF(100, 100) //! [5] -//! [6] -// Rotate an item 45 degrees around (0, 0). -item->rotate(45); - -// Rotate an item 45 degrees around (x, y). -item->setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y)); -//! [6] - - -//! [7] -// Scale an item by 3x2 from its origin -item->scale(3, 2); - -// Scale an item by 3x2 from (x, y) -item->setTransform(QTransform().translate(x, y).scale(3, 2).translate(-x, -y)); -//! [7] - - //! [8] QRectF CircleItem::boundingRect() const { @@ -223,19 +205,3 @@ QTransform xform = item->deviceTransform(view->viewportTransform()); QRect deviceRect = xform.mapRect(rect).toAlignedRect(); view->viewport()->scroll(dx, dy, deviceRect); //! [19] - -//! [20] -item->setTransform(QTransform().rotate(angle), true); -//! [20] - -//! [21] -setTransform(QTransform::fromScale(sx, sy), true); -//! [21] - -//! [22] -setTransform(QTransform().shear(sh, sv), true); -//! [22] - -//! [23] -setTransform(QTransform::fromTranslate(dx, dy), true); -//! [23] diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp index 9f48c4e06b..0b757cf0a2 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp @@ -27,16 +27,6 @@ view.setCacheMode(QGraphicsView::CacheBackground); //! [2] -//! [3] -QGraphicsScene scene; -scene.addText("GraphicsView rotated clockwise"); - -QGraphicsView view(&scene); -view.rotate(90); // the text is rendered with a 90 degree clockwise rotation -view.show(); -//! [3] - - //! [4] QGraphicsScene scene; scene.addItem(... diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp index a31e720fb1..0d14b086cc 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp @@ -31,26 +31,6 @@ QApplication::setStyle(QStyleFactory::create("Fusion")); //! [1] -// ### fixme: Qt 6: Remove [2] -//! [2] -int main(int argc, char *argv[]) -{ - QApplication::setColorSpec(QApplication::ManyColor); - QApplication app(argc, argv); - ... - return app.exec(); -} -//! [2] - - -//! [3] -QSize MyWidget::sizeHint() const -{ - return QSize(80, 25); -} -//! [3] - - //! [4] void showAllHiddenTopLevelWidgets() { @@ -73,82 +53,8 @@ void updateAllWidgets() //! [5] -//! [6] -int main(int argc, char *argv[]) -{ - QApplication::setDesktopSettingsAware(false); - QApplication app(argc, argv); - ... - return app.exec(); -} -//! [6] - - //! [7] if ((startPos - currentPos).manhattanLength() >= QApplication::startDragDistance()) startTheDrag(); //! [7] - - -//! [8] -void MyApplication::commitData(QSessionManager& manager) -{ - if (manager.allowsInteraction()) { - int ret = QMessageBox::warning( - mainWindow, - tr("My Application"), - tr("Save changes to document?"), - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - switch (ret) { - case QMessageBox::Save: - manager.release(); - if (!saveDocument()) - manager.cancel(); - break; - case QMessageBox::Discard: - break; - case QMessageBox::Cancel: - default: - manager.cancel(); - } - } else { - // we did not get permission to interact, then - // do something reasonable instead - } -} -//! [8] - - -//! [9] -appname -session id -//! [9] - - -//! [10] -const QStringList commands = mySession.restartCommand(); -for (const QString &command : commands) - do_something(command); -//! [10] - - -//! [11] -const QStringList commands = mySession.discardCommand(); -for (const QString &command : commands) - do_something(command); -//! [11] - - -//! [12] -QWidget *widget = QApplication::widgetAt(x, y); -if (widget) - widget = widget->window(); -//! [12] - - -//! [13] -QWidget *widget = QApplication::widgetAt(point); -if (widget) - widget = widget->window(); -//! [13] diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp index 603ce14f80..21703c7395 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp @@ -22,19 +22,6 @@ aWidget->window()->setWindowTitle("New Window Title"); //! [3] -//! [4] -QFont font("Helvetica", 12, QFont::Bold); -setFont(font); -//! [4] - - -//! [5] -QFont font; -font.setBold(false); -setFont(font); -//! [5] - - //! [6] setCursor(Qt::IBeamCursor); //! [6] diff --git a/src/widgets/doc/snippets/splitter/splitter.cpp b/src/widgets/doc/snippets/splitter/splitter.cpp index c3a36ba4c0..662ac30eda 100644 --- a/src/widgets/doc/snippets/splitter/splitter.cpp +++ b/src/widgets/doc/snippets/splitter/splitter.cpp @@ -37,11 +37,5 @@ int main() //! [2] } -//! [3] - QListIterator<int> it(splitter->sizes()); - while (it.hasNext()) - processSize(it.next()); -//! [3] - return 0; } diff --git a/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp b/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp index a97a5afcf6..7c7a59745b 100644 --- a/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp +++ b/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp @@ -89,17 +89,6 @@ for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) //! [10] } -void FirstElement() -{ -//! [11] -QDomDocument doc; -QDomElement root = doc.firstChildElement("database"); -QDomElement elt = root.firstChildElement("entry"); -for (; !elt.isNull(); elt = elt.nextSiblingElement("entry")) { - // ... -} -//! [11] -} void FileContent() { diff --git a/src/xml/doc/snippets/code/src_xml_sax_qxml.cpp b/src/xml/doc/snippets/code/src_xml_sax_qxml.cpp deleted file mode 100644 index f64a6b8b1b..0000000000 --- a/src/xml/doc/snippets/code/src_xml_sax_qxml.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//! [0] -xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); -//! [0] diff --git a/src/xml/doc/snippets/rsslisting/handler.cpp b/src/xml/doc/snippets/rsslisting/handler.cpp index ef2df04653..d1a4243632 100644 --- a/src/xml/doc/snippets/rsslisting/handler.cpp +++ b/src/xml/doc/snippets/rsslisting/handler.cpp @@ -133,7 +133,6 @@ bool Handler::characters (const QString &chars) that parsing should stop. */ -//! [0] bool Handler::fatalError (const QXmlParseException & exception) { qWarning() << "Fatal error on line" << exception.lineNumber() @@ -142,4 +141,3 @@ bool Handler::fatalError (const QXmlParseException & exception) return false; } -//! [0] diff --git a/src/xml/doc/snippets/rsslisting/listing.cpp b/src/xml/doc/snippets/rsslisting/listing.cpp index d7fd28d56c..4b85e1aabb 100644 --- a/src/xml/doc/snippets/rsslisting/listing.cpp +++ b/src/xml/doc/snippets/rsslisting/listing.cpp @@ -110,10 +110,8 @@ void RSSListing::fetch() delete handler; handler = new Handler; -//! [0] xmlReader.setContentHandler(handler); xmlReader.setErrorHandler(handler); -//! [0] connect(handler, SIGNAL(newItem(QString&,QString&)), this, SLOT(addItem(QString&,QString&))); @@ -136,7 +134,6 @@ void RSSListing::fetch() If parsing fails for any reason, we abort the fetch. */ -//! [1] void RSSListing::readData(const QHttpResponseHeader &resp) { bool ok; @@ -157,7 +154,6 @@ void RSSListing::readData(const QHttpResponseHeader &resp) http.abort(); } } -//! [1] /* Finishes processing an HTTP request. |