0

This is a sequel to another question here in which I was not precise while describing my goal.

As mentioned in the linked question, I wish to save a QML which is embedded in a QQuickWidget and it is larger than the window size. The QQuickWindow grabWindow() method captures only the window area and hence I tried the following code after I visually displayed it:

QQuickWidget* content..
content->setSource(QUrl("qml:/main.qml"));
QPixmap *pm = content->grab(QRect(QPoint(0,0),QSize(-1,-1));
pm->save("someFilename.png", 0, 100);

So, it is definitely not the issue of saving image after rendering. The used QML code is just a plain Rectangle. The proposed solutions in the previous question only grabs content falling within the window.

Any suggestions? Thanks! :)

Addendum:

I have tried the following but didn't work:

QImage paintdev(largeWidth, largeHeight, QImage:Format_RBG32);
content->render(paintdev, QPoint(0,0), QRegion(QRect(0,0,largeWidth, largeHeight), QWidget::DrawChildren);
paintdev.save(fileName, 0, 100);

This should by logic solve the issue of window size since there is no window. Any comments?

Community
  • 1
  • 1

2 Answers2

2

Ok, so I solved it by manually shifting the QML by the window height and saving all the images from the window captures and collate it to form the original image.

Not too much work though, but I am still mystified by the QWidget render() method which did not work.

Thanks for all the replies!

BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82
0

If your QML content is larger than the window size, the part that is out of screen is not drawn. Hence, there is no way to capture something out of screen, unless you use 2 monitors and extend view. This last approach would work.

BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82
Mido
  • 1,092
  • 1
  • 9
  • 14
  • Will my above mentioned code using QWidget grab() method capture the whole widget regardless of the size of the widget? --ok, I now understand: The part outside screen is not drawn and hence not possible to be captured. – neoterryjoe Jul 22 '15 at 10:14