How to print a part of an Item?
-
An Item has a huge size. Let's say 500000X500000. And the Item has thousands of childItems.
Then I want to print a part of this Item(including its children), the letftop is a point in this Item,the width and height are 3000 pixels.
I found the method of QQuickItem::grabToImage that can grab the whole Item.But I don‘t find a method can grab a part of an Item.
Is there a method that can grab a part of Item into Image? -
-
You can specify the target size in functions parameter: https://doc.qt.io/qt-5/qquickitem.html#grabToImage-1. The QML version also has target size https://doc.qt.io/qt-6/qml-qtquick-item.html#grabToImage-method
-
That's the target size, not the source rect which OP seems to want. As mentionned by fcarney you could get a part of the item by calling
grabToImage
on aShaderEffectSource
withsourceItem
andsourceRect
set accordingly. -
You can also call
grabToImage
on anItem
that you manually set to correct size.