Hi,

I would like to process an image loaded into a Flickable QML element in C++ land but I am failing to obtain the original image. So far I'm only seem able to obtain an image of the QQuickWindow
and would liek to know if there is a way to obtain the whole loaded image.

I am calling a Q_INVOKABLE method of a C++ object as follows:


Qt Code:
  1. Flickable {
  2. id: content
  3. clip: false
  4. anchors.fill: parent
  5. boundsBehavior: Flickable.StopAtBounds
  6.  
  7. Loader {
  8. id: contentLoader
  9. anchors.centerIn: parent
  10. }
  11.  
  12. MouseArea {
  13. anchors.fill: parent
  14. onClicked: {
  15. console.log("[veo] onClicked - capture triggered")
  16. cplusplusobject.process(contentLoader.item) <----------------- call to C++
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 


In C++ I have:

Qt Code:
  1. void
  2. Cplusplusobject::process(const QVariant &v)
  3. {
  4. qDebug() << "[veo]" << __FUNCTION__;
  5. QQuickItem *item = qobject_cast<QQuickItem *>( v.value<QObject*>() );
  6. qDebug() << "Item dimensions:" << item->width() << item->height();
  7.  
  8. item->dumpObjectInfo();
  9.  
  10. QQuickWindow *window = item->window();
  11. QImage image = window->grabWindow();
  12. ...
To copy to clipboard, switch view to plain text mode 

The printed item dimensions do correspond to the original image but I fail to see how to turn the QQuickItem into a QImage.

Any suggestions please?