FormEditor: Return correct bounding rect for rendered QPicture

The bounding rect is calculated by union of all child item boundings rect
of all FormEditorItems.

Change-Id: I908e9d08b581671436bc7334b3b7eb0a5cd25aa8
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Michael Winkelmann
2020-11-30 16:29:02 +01:00
parent 5c5c023304
commit 7048a89fa1

View File

@@ -512,8 +512,13 @@ QPicture FormEditorWidget::renderToPicture() const
QPainter painter{&picture}; QPainter painter{&picture};
const QTransform viewportTransform = m_graphicsView->viewportTransform(); const QTransform viewportTransform = m_graphicsView->viewportTransform();
const QRectF boundingRect = rootItemRect(); auto items = m_formEditorView->scene()->allFormEditorItems();
QRectF boundingRect;
for (auto &item : items)
boundingRect |= item->childrenBoundingRect();
picture.setBoundingRect(boundingRect.toRect());
m_graphicsView->render(&painter, boundingRect, viewportTransform.mapRect(boundingRect.toRect())); m_graphicsView->render(&painter, boundingRect, viewportTransform.mapRect(boundingRect.toRect()));
return picture; return picture;