summaryrefslogtreecommitdiffstats
path: root/examples/graphicsview/flowlayout/window.cpp
blob: b632bc97e17dfbd64f03353f133a9e85ecaf3b32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qlabel.h>
#include "flowlayout.h"
#include "window.h"

Window::Window()
: QGraphicsWidget(0, Qt::Window)
{
    FlowLayout *lay = new FlowLayout;
    QString sentence(QLatin1String("I am not bothered by the fact that I am unknown. I am bothered when I do not know others."));
    QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts);
    for (int i = 0; i < words.count(); ++i) {
        QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
        QLabel *label = new QLabel(words.at(i));
        label->setFrameStyle(QFrame::Box | QFrame::Plain);
        proxy->setWidget(label);
        lay->addItem(proxy);
    }
    setLayout(lay);
}