1

I have a very simple task that has resulted in going around in circles mainly because of the separation of QML and C++ side of QT. So instead of asking specific QT questions I need general advice on what QT and QML functions I should use to achieve my usecase.

Usecase:

A QQuickControls UI allows a user to select an image. That image is shown in the UI. When the user clicks the button 'Process' the application finds edges.

My question is; how can I overwrite the currently being shown image? Should I use a Q_INVOKABLE function? Or a signal or slot? My below code has created the UI, allows a user to select an image (and displays it), generates the edge image when the 'Process' button is clicked. It just doesn't display that new edge image because I don't know how to achieve this in QT/QQuickControls2.

Any advice how to implement this in QT would be greatly appreciated.

sazr
  • 24,984
  • 66
  • 194
  • 362

1 Answers1

1

What we have:

  • QML UI with a placeholder for the image and the button to trigger new image.
  • C++ ImageProcessor QML type for generating the new image from OpenCV Mat.

The easiest solution would be:

Mind that there a few more solutions for more dynamic rendering with QQuickFramebufferObject and QQuickpainteditem and QAbstractVideoSurface that worth effort when the image is not static etc.

P.S. I also suggest you to rename the question as long as it is not really about how exactly to execute C++ code from QML but how to make a QML-compatible image and actually render it.

Alexander V
  • 8,351
  • 4
  • 38
  • 47