qmlglsink: QT integration in python not working due to mismatch for PyQT
Hello,
I am trying to use PyQT5 with qmlglsink: Qt: v 5.9.5 PyQt: v 5.10.1
Error given: TypeError: could not convert '<PyQt5.QtQuick.QQuickItem object at 0x7f746b0dc8>' to type 'gpointer' when setting property 'GstQtSink.widget'
Example code:
import sys
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQml import QQmlApplicationEngine
import PyQt5.QtQuick as QtQuick
import gi
gi.require_version("Gst", "1.0")
gi.require_version("GstVideo", "1.0")
from gi.repository import GObject, Gst, GstVideo
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.quit.connect(app.quit)
GObject.threads_init()
Gst.init(None)
class GstDisplay:
def __init__(self):
pipeline = "videotestsrc ! glupload ! qmlglsink name=sink"
self.pipeline = Gst.parse_launch(pipeline) # xvimagesink, ximagesink
self.setup_pipeline()
self.sink = self.pipeline.get_by_name("sink")
def setup_pipeline(self):
self.state = Gst.State.NULL
bus = self.pipeline.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
def start_pipeline(self):
self.pipeline.set_state(Gst.State.PLAYING)
gstpipe=GstDisplay()
gstpipe.start_pipeline()
engine.load('main.qml')
root=engine.rootObjects()[0]
videoItem=engine.rootObjects()[0].findChild(QtQuick.QQuickItem,name="videoItem")
gstpipe.sink.set_property("widget", videoItem)```
main.qml:
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtMultimedia 5.0
import org.freedesktop.gstreamer.GLVideoItem 1.0
ApplicationWindow {
visible: true
width: 1920
height: 1080
title: "HelloApp"
GstGLVideoItem {
id: video
objectName: "videoItem"
anchors.centerIn: parent
width: parent.width
height: parent.height
}
}