summaryrefslogtreecommitdiffstats
path: root/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-26 14:38:54 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-11 19:25:47 +0000
commitbcd7d223f066f2830501c2be79f1e7e4f6dd8f50 (patch)
tree2731bb0009263cb2c8d6365a0fedaf2ae63ab8db /src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp
parent276d6cf239bdb0a39ae589e13f60b2a31a2efb60 (diff)
QtGui: eradicate Q_FOREACH loops [rvalues]
... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Change-Id: I457942159015ff153bdfc6d5f031a3f0a0f6e9ac Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp')
-rw-r--r--src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp6
1 files changed, 4 insertions, 2 deletions
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 8177927a8b..cbe476bc5a 100644
--- a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp
+++ b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp
@@ -89,7 +89,8 @@ QSize MyWidget::sizeHint() const
//! [4]
void showAllHiddenTopLevelWidgets()
{
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ const auto topLevelWidgets = QApplication::topLevelWidgets();
+ for (QWidget *widget : topLevelWidgets) {
if (widget->isHidden())
widget->show();
}
@@ -100,7 +101,8 @@ void showAllHiddenTopLevelWidgets()
//! [5]
void updateAllWidgets()
{
- foreach (QWidget *widget, QApplication::allWidgets())
+ const auto topLevelWidgets = QApplication::topLevelWidgets();
+ for (QWidget *widget : topLevelWidgets)
widget->update();
}
//! [5]