can not display a video with qml sink within qwidgets layout
-
I am trying to use qml sink inside a qwidget and play video with a gstreamer pipeline. When I start to play the video, I get the following error:
error Could not initialize window system
Debugging info: gstqtsink.cc(309): gst_qt_sink_change_state (): /GstGLSinkBin:glsinkbin0/GstQtSink:sinkPure qml code works fine.
Did anyone have the similar problems before? I know it is not a good idea to mix qml with qwidgets. Unluckily, I do not have other choices for now.
Qt 5.15.2 + Ubuntu 18.04 + gstreamer 1.14
Qt 5.15.3 + Ubuntu 22.04 + gstreamer 1.22 -
@SGaist Tried it and got the exactly same errors:
error Could not initialize window system
Debugging info: gstqtsink.cc(309): gst_qt_sink_change_state (): /GstGLSinkBin:glsinkbin0/GstQtSink:sinkMore error output:
0:00:00.412321063 11575 0x555f6545be00 ERROR qtglwidget qtitem.cc:336:initWinSys: 0x555f657c5a20 failed to retrieve wrapped context (NULL)
0:00:00.412390280 11575 0x555f6545be00 ERROR playbin gstplaybin2.c:5444:activate_group:<playbin0> failed to activate sinks -
I am trying to use qml sink inside a qwidget and play video with a gstreamer pipeline. When I start to play the video, I get the following error:
error Could not initialize window system
Debugging info: gstqtsink.cc(309): gst_qt_sink_change_state (): /GstGLSinkBin:glsinkbin0/GstQtSink:sinkPure qml code works fine.
Did anyone have the similar problems before? I know it is not a good idea to mix qml with qwidgets. Unluckily, I do not have other choices for now.
Qt 5.15.2 + Ubuntu 18.04 + gstreamer 1.14
Qt 5.15.3 + Ubuntu 22.04 + gstreamer 1.22Hi,
How did you implement it ? Using a QQuickWidget ?
-
Hi,
How did you implement it ? Using a QQuickWidget ?
@SGaist Thanks for your reply. I tried both.
class MyWidget: public QQuickWidget { }; MyWidget::MyWidget( QWidget * parent ) : QQuickWidget( parent ) { setWindowFlags( Qt::FramelessWindowHint | Qt::WindowTitleHint ); auto vbox_layout = new QVBoxLayout( this ); vbox_layout->setContentsMargins( 0, 0, 0, 0 ); QUrl source("qrc:res/StreamingRect.qml"); m_quickView = new QQuickView; m_quickView->setResizeMode( QQuickView::SizeRootObjectToView ); m_quickView->setSource( source ); m_currentRootObject = m_quickView->rootObject(); m_quickWidget = QWidget::createWindowContainer( m_quickView ); vbox_layout->addWidget( m_quickWidget ); if ( m_currentRootObject ) { m_currentRootObject->setProperty( "m_height", size().height() ); m_currentRootObject->setProperty( "m_width", size().width() ); m_currentRootObject->setProperty( "m_visible", true ); } }
-
@SGaist Thanks for your reply. I tried both.
class MyWidget: public QQuickWidget { }; MyWidget::MyWidget( QWidget * parent ) : QQuickWidget( parent ) { setWindowFlags( Qt::FramelessWindowHint | Qt::WindowTitleHint ); auto vbox_layout = new QVBoxLayout( this ); vbox_layout->setContentsMargins( 0, 0, 0, 0 ); QUrl source("qrc:res/StreamingRect.qml"); m_quickView = new QQuickView; m_quickView->setResizeMode( QQuickView::SizeRootObjectToView ); m_quickView->setSource( source ); m_currentRootObject = m_quickView->rootObject(); m_quickWidget = QWidget::createWindowContainer( m_quickView ); vbox_layout->addWidget( m_quickWidget ); if ( m_currentRootObject ) { m_currentRootObject->setProperty( "m_height", size().height() ); m_currentRootObject->setProperty( "m_width", size().width() ); m_currentRootObject->setProperty( "m_visible", true ); } }
-
@SGaist Thanks for your reply. I tried both.
class MyWidget: public QQuickWidget { }; MyWidget::MyWidget( QWidget * parent ) : QQuickWidget( parent ) { setWindowFlags( Qt::FramelessWindowHint | Qt::WindowTitleHint ); auto vbox_layout = new QVBoxLayout( this ); vbox_layout->setContentsMargins( 0, 0, 0, 0 ); QUrl source("qrc:res/StreamingRect.qml"); m_quickView = new QQuickView; m_quickView->setResizeMode( QQuickView::SizeRootObjectToView ); m_quickView->setSource( source ); m_currentRootObject = m_quickView->rootObject(); m_quickWidget = QWidget::createWindowContainer( m_quickView ); vbox_layout->addWidget( m_quickWidget ); if ( m_currentRootObject ) { m_currentRootObject->setProperty( "m_height", size().height() ); m_currentRootObject->setProperty( "m_width", size().width() ); m_currentRootObject->setProperty( "m_visible", true ); } }
@JoeCFD
I make a simple case and display it in the main. Eventually I will add it to my app. I would like to make sure the sink works fine. StreamingRect.qml has a qml sink and it is added to the pipeline without any issue. The same qml file is used in a pure qml app and works fine.int main( int argc, char * argv[] ) { auto app = new QApplication( argc, argv ); app->setStyle( "Fusion" ); QSize size( 800, 600 ); auto streamer = new MyWidget ( nullptr ); streamer->resize( size ); streamer->setVisible( true ); return app->exec(); }
-
@JoeCFD
I make a simple case and display it in the main. Eventually I will add it to my app. I would like to make sure the sink works fine. StreamingRect.qml has a qml sink and it is added to the pipeline without any issue. The same qml file is used in a pure qml app and works fine.int main( int argc, char * argv[] ) { auto app = new QApplication( argc, argv ); app->setStyle( "Fusion" ); QSize size( 800, 600 ); auto streamer = new MyWidget ( nullptr ); streamer->resize( size ); streamer->setVisible( true ); return app->exec(); }
The issue here is that rather than using QQuickWidget as a qml container, you create a second QML container widget that you put on top of it.
-
The issue here is that rather than using QQuickWidget as a qml container, you create a second QML container widget that you put on top of it.
-
@SGaist I tried to use QWidget as well. I need to put it somewhere in the layout of my app anyway later.
-
@SGaist Tried it and got the exactly same errors:
error Could not initialize window system
Debugging info: gstqtsink.cc(309): gst_qt_sink_change_state (): /GstGLSinkBin:glsinkbin0/GstQtSink:sinkMore error output:
0:00:00.412321063 11575 0x555f6545be00 ERROR qtglwidget qtitem.cc:336:initWinSys: 0x555f657c5a20 failed to retrieve wrapped context (NULL)
0:00:00.412390280 11575 0x555f6545be00 ERROR playbin gstplaybin2.c:5444:activate_group:<playbin0> failed to activate sinks -
@SGaist Tried it and got the exactly same errors:
error Could not initialize window system
Debugging info: gstqtsink.cc(309): gst_qt_sink_change_state (): /GstGLSinkBin:glsinkbin0/GstQtSink:sinkMore error output:
0:00:00.412321063 11575 0x555f6545be00 ERROR qtglwidget qtitem.cc:336:initWinSys: 0x555f657c5a20 failed to retrieve wrapped context (NULL)
0:00:00.412390280 11575 0x555f6545be00 ERROR playbin gstplaybin2.c:5444:activate_group:<playbin0> failed to activate sinks -
J JoeCFD has marked this topic as solved on
-
J JoeCFD referenced this topic on