Debian Codegraph @

tests/manual/examples/widgets/graphicsview/flowlayout/window.cpp

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4 #include "window.h"
5 #include "flowlayout.h"
6
7 #include <QGraphicsProxyWidget>
8 #include <QLabel>
9
10 Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window)
11 {
12 FlowLayout *lay = new FlowLayout;
13 const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown."
14 " I am bothered when I do not know others. (Confucius)"));
15 const QList<QStringView> words = QStringView{ sentence }.split(QLatin1Char(' '), Qt::SkipEmptyParts);
16 for (const QStringView &word : words) {
17 QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
18 QLabel *label = new QLabel(word.toString());
19 label->setFrameStyle(QFrame::Box | QFrame::Plain);
20 proxy->setWidget(label);
21 lay->addItem(proxy);
22 }
23 setLayout(lay);
24 }