From cf42b485ebc1ab3e1f0a804b8c4e404fa99f1f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 6 Apr 2009 14:13:39 +0200 Subject: Fix a small bugs in the example. +two small cleanups. --- examples/graphicsview/flowlayout/flowlayout.cpp | 6 +++--- examples/graphicsview/flowlayout/flowlayout.h | 2 +- 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(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); -- cgit v0.12