diff options
Diffstat (limited to 'examples/graphicsview/flowlayout/window.cpp')
-rw-r--r-- | examples/graphicsview/flowlayout/window.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp new file mode 100644 index 0000000..b632bc9 --- /dev/null +++ b/examples/graphicsview/flowlayout/window.cpp @@ -0,0 +1,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); +}
\ No newline at end of file |