diff options
Diffstat (limited to 'src/widgets/doc/snippets/code')
6 files changed, 33 insertions, 71 deletions
diff --git a/src/widgets/doc/snippets/code/doc_src_examples_dropsite.qdoc b/src/widgets/doc/snippets/code/doc_src_examples_dropsite.qdoc deleted file mode 100644 index a91933cdce..0000000000 --- a/src/widgets/doc/snippets/code/doc_src_examples_dropsite.qdoc +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -\code -foreach(variable, container) -\endcode -//! [0] diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc index 9af04f6b4c..098eaf4717 100644 --- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc +++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc @@ -514,13 +514,15 @@ QLabel { border-width: 1px 2px 3px 4px } /* 1px 2px 3px 4px */ //! [84] -QLabel { border-color: red } /* opaque red */ -QLabel { border-color: #FF0000 } /* opaque red */ -QLabel { border-color: rgba(255, 0, 0, 75%) } /* 75% opaque red */ -QLabel { border-color: rgb(255, 0, 0) } /* opaque red */ -QLabel { border-color: rgb(100%, 0%, 0%) } /* opaque red */ -QLabel { border-color: hsv(60, 255, 255) } /* opaque yellow */ -QLabel { border-color: hsva(240, 255, 255, 75%) } /* 75% blue */ +QLabel { border-color: red } /* opaque red */ +QLabel { border-color: #FF0000 } /* opaque red */ +QLabel { border-color: rgba(255, 0, 0, 75%) } /* 75% opaque red */ +QLabel { border-color: rgb(255, 0, 0) } /* opaque red */ +QLabel { border-color: rgb(100%, 0%, 0%) } /* opaque red */ +QLabel { border-color: hsv(60, 100%, 100%) } /* opaque yellow */ +QLabel { border-color: hsva(240, 255, 255, 75%) } /* 75% blue */ +QLabel { border-color: hsl(60, 100%, 50%) } /* opaque yellow */ +QLabel { border-color: hsla(240, 255, 50%, 75%) } /* 75% blue */ //! [84] diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp index 06cca37111..1e9daf824b 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp @@ -144,3 +144,14 @@ dialog.exec(); //! [14] "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" //! [14] + +//! [14] +auto fileOpenCompleted = [](const QSting &fileName, const QByteArray &fileContent) { + if (fileName.isEmpty()) { + // No file was selected + } else { + // Use fileName and fileContent + } +} +QFileDialog::getOpenFileContent("Images (*.png *.xpm *.jpg)", fileContentReady); +//! [14] diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp index 4dad563660..cc1568cb9d 100644 --- a/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp +++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp @@ -59,7 +59,7 @@ mapper->toFirst(); //! [1] -QDataWidgetMapper *mapper = new QDataWidgetMapper(); +QDataWidgetMapper *mapper = new QDataWidgetMapper; mapper->setModel(myModel); mapper->addMapping(nameLineEdit, 0); mapper->addMapping(ageSpinBox, 1); @@ -67,7 +67,7 @@ mapper->addMapping(ageSpinBox, 1); //! [2] -QDataWidgetMapper *mapper = new QDataWidgetMapper(); -connect(myTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), - mapper, SLOT(setCurrentModelIndex(QModelIndex))); +QDataWidgetMapper *mapper = new QDataWidgetMapper; +connect(myTableView->selectionModel(), &QItemSelectionModel::currentRowChanged, + mapper, &QDataWidgetMapper::setCurrentModelIndex); //! [2] 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 a907a0421f..0a70c1d32a 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp @@ -100,7 +100,8 @@ QSize MyWidget::sizeHint() const //! [4] void showAllHiddenTopLevelWidgets() { - foreach (QWidget *widget, QApplication::topLevelWidgets()) { + const QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); + for (QWidget *widget : topLevelWidgets) { if (widget->isHidden()) widget->show(); } @@ -111,7 +112,8 @@ void showAllHiddenTopLevelWidgets() //! [5] void updateAllWidgets() { - foreach (QWidget *widget, QApplication::allWidgets()) + const QWidgetList allWidgets = QApplication::allWidgets(); + for (QWidget *widget : allWidgets) widget->update(); } //! [5] @@ -171,13 +173,15 @@ appname -session id //! [10] -foreach (const QString &command, mySession.restartCommand()) +const QStringList commands = mySession.restartCommand(); +for (const QString &command : commands) do_something(command); //! [10] //! [11] -foreach (const QString &command, mySession.discardCommand()) +const QStringList commands = mySession.discardCommand(); +for (const QString &command : commands) do_something(command); //! [11] diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp index 4b1c4cd645..da3fd28056 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp @@ -81,7 +81,7 @@ exec(e->globalPos()); //! [6] QMenu menu; QAction *at = actions[0]; // Assumes actions is not empty -foreach (QAction *a, actions) +for (QAction *a : qAsConst(actions)) menu.addAction(a); menu.exec(pos, at); //! [6] |