Home > Mobile >  Transport QML Image via Bridge
Transport QML Image via Bridge

Time:07-12

I have at the moment a simple PySide6 app which uses qml for image capturing. I want to transport the image to our app but cannot figure out how. I am not sure, if enter image description here

What is missing?

In the Button with id: takePicButton I want to transport the image to the PySide6 Bridge. If I add to theonClicked Signal bridge.capture(capture.preview) I got the Error:

TypeError: Passing incompatible arguments to C   functions from JavaScript is not allowed.`

How can I solve this problem?

CodePudding user response:

You should use the imageCaptured signal.

Change:

imageCapture: ImageCapture {
    id: capture
}

To:

imageCapture: ImageCapture {
    id: capture
    onImageCaptured: function(req_id, preview){bridge.capture(req_id, preview)}
}

And change in main.py:

@Slot(QImage)
def capture(self, preview):
    # Do something with the preview
    print(type(preview))

To:

@Slot(int, QImage)
def capture(self,req_id, preview):
    print(req_id)
    print(type(preview))

Working example here.
You might want to look at this answer for other use cases.

  • Related