diff --git a/widgets/scrollwidget.cpp b/widgets/scrollwidget.cpp index 37795bb0c..f6c93fe1f 100644 --- a/widgets/scrollwidget.cpp +++ b/widgets/scrollwidget.cpp @@ -214,6 +214,14 @@ public: (widget->pos() + delta).toPoint()); } + void makeItemVisible() + { + QRectF rect(widget->mapFromScene(itemToBeVisible->scenePos()), itemToBeVisible->boundingRect().size()); + rectToBeVisible = rect; + + makeRectVisible(); + } + void cleanupDragHandles(QObject *destroyed) { dragHandles.remove(static_cast(destroyed)); @@ -233,6 +241,7 @@ public: ScrollBar *horizontalScrollBar; Qt::ScrollBarPolicy horizontalScrollBarPolicy; QString styleSheet; + QGraphicsItem *itemToBeVisible; QRectF rectToBeVisible; QPointF dragHandleClicked; QSetdragHandles; @@ -351,11 +360,10 @@ void ScrollWidget::ensureItemVisible(QGraphicsItem *item) parentOfItem = parentOfItem->parentItem(); } - QRectF rect(d->widget->mapFromScene(item->scenePos()), item->boundingRect().size()); - d->rectToBeVisible = rect; + d->itemToBeVisible = item; // We need to wait for the parent item to resize... - QTimer::singleShot(0, this, SLOT(makeRectVisible())); + QTimer::singleShot(0, this, SLOT(makeItemVisible())); } void ScrollWidget::registerAsDragHandle(QGraphicsWidget *item) diff --git a/widgets/scrollwidget.h b/widgets/scrollwidget.h index 2c1e5a0b4..59aed0eac 100644 --- a/widgets/scrollwidget.h +++ b/widgets/scrollwidget.h @@ -198,6 +198,7 @@ private: Q_PRIVATE_SLOT(d, void verticalScroll(int value)) Q_PRIVATE_SLOT(d, void horizontalScroll(int value)) Q_PRIVATE_SLOT(d, void makeRectVisible()) + Q_PRIVATE_SLOT(d, void makeItemVisible()) Q_PRIVATE_SLOT(d, void cleanupDragHandles(QObject *destroyed)) };