diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-09-01 17:12:01 +0200 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-09-05 17:40:36 +0200 |
commit | 6f4bc3942dda076eedf38d8c8604eb4fa5d7bd3b (patch) | |
tree | 5813b88711ccfc1bb6f6948c1534fa407d4a4262 /examples/widgets/graphicsview/flowlayout/window.cpp | |
parent | 42011c03613b38d2bf9c7770edf1392c5f5598f2 (diff) |
Widgets/GraphicsView examples: cleanup
Cleanup GraphicsView examples with the help of clang-tidy
- modernize-use-nullptr
- modernize-use-default-member-init
- modernize-use-override.IgnoreDestructors
- Some QList -> QVector changes
- use nullptr
- use normalized includes, remove unused includes
- fix style
Change-Id: I79347e55bfde52f6ae7749cc7093fbd442044020
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/widgets/graphicsview/flowlayout/window.cpp')
-rw-r--r-- | examples/widgets/graphicsview/flowlayout/window.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/examples/widgets/graphicsview/flowlayout/window.cpp b/examples/widgets/graphicsview/flowlayout/window.cpp index 34d0d71b44..8fe06d0e11 100644 --- a/examples/widgets/graphicsview/flowlayout/window.cpp +++ b/examples/widgets/graphicsview/flowlayout/window.cpp @@ -48,23 +48,21 @@ ** ****************************************************************************/ -#include "flowlayout.h" #include "window.h" +#include "flowlayout.h" #include <QGraphicsProxyWidget> #include <QLabel> -Window::Window() -: QGraphicsWidget(0, Qt::Window) +Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window) { FlowLayout *lay = new FlowLayout; - QLatin1String wiseWords("I am not bothered by the fact that I am unknown." - " I am bothered when I do not know others. (Confucius)"); - QString sentence(wiseWords); - QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); - for (int i = 0; i < words.count(); ++i) { + const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown." + " I am bothered when I do not know others. (Confucius)")); + const QVector<QStringRef> words = sentence.splitRef(QLatin1Char(' '), QString::SkipEmptyParts); + for (const QStringRef &word : words) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); - QLabel *label = new QLabel(words.at(i)); + QLabel *label = new QLabel(word.toString()); label->setFrameStyle(QFrame::Box | QFrame::Plain); proxy->setWidget(label); lay->addItem(proxy); |