diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-04-06 12:13:39 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-04-06 12:14:52 (GMT) |
commit | cf42b485ebc1ab3e1f0a804b8c4e404fa99f1f6f (patch) | |
tree | 8f61ec20451aed2ea8223e32bc50862e1e2ca8ba /examples/graphicsview/flowlayout | |
parent | 6d1ba5590c99ad92de75ecd8bc9921921123d809 (diff) | |
download | Qt-cf42b485ebc1ab3e1f0a804b8c4e404fa99f1f6f.zip Qt-cf42b485ebc1ab3e1f0a804b8c4e404fa99f1f6f.tar.gz Qt-cf42b485ebc1ab3e1f0a804b8c4e404fa99f1f6f.tar.bz2 |
Fix a small bugs in the example. +two small cleanups.
Diffstat (limited to 'examples/graphicsview/flowlayout')
-rw-r--r-- | examples/graphicsview/flowlayout/flowlayout.cpp | 6 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/flowlayout.h | 2 | ||||
-rw-r--r-- | examples/graphicsview/flowlayout/window.cpp | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp index 9bbe8a4..d36c37f 100644 --- a/examples/graphicsview/flowlayout/flowlayout.cpp +++ b/examples/graphicsview/flowlayout/flowlayout.cpp @@ -74,6 +74,7 @@ QGraphicsLayoutItem *FlowLayout::itemAt(int index) const void FlowLayout::removeAt(int index) { m_items.removeAt(index); + invalidate(); } qreal FlowLayout::spacing(Qt::Orientation o) const @@ -95,7 +96,7 @@ void FlowLayout::setGeometry(const QRectF &geom) doLayout(geom, true); } -qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) +qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const { QPointF tl = geom.topLeft(); qreal maxw = geom.width(); @@ -139,8 +140,7 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const qreal left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); if (constraint.width() > 0) { // height for width - FlowLayout *that = const_cast<FlowLayout *>(this); - qreal height = that->doLayout(QRectF(QPointF(0,0), constraint), false); + qreal height = doLayout(QRectF(QPointF(0,0), constraint), false); size = QSizeF(constraint.width(), height); } else { QGraphicsLayoutItem *item; diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h index a78a83a..c1e5635 100644 --- a/examples/graphicsview/flowlayout/flowlayout.h +++ b/examples/graphicsview/flowlayout/flowlayout.h @@ -61,7 +61,7 @@ protected: QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; private: - qreal doLayout(const QRectF &geom, bool applyNewGeometry); + qreal doLayout(const QRectF &geom, bool applyNewGeometry) const; QSizeF minSize(const QSizeF &constraint) const; QSizeF prefSize() const; QSizeF maxSize() const; diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp index f14066e..dd53b56 100644 --- a/examples/graphicsview/flowlayout/window.cpp +++ b/examples/graphicsview/flowlayout/window.cpp @@ -48,7 +48,9 @@ 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.")); + 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) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); |