Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. can not display a video with qml sink within qwidgets layout
Forum Updated to NodeBB v4.3 + New Features

can not display a video with qml sink within qwidgets layout

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #1

    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:sink

    Pure 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

    SGaistS 1 Reply Last reply
    0
    • JoeCFDJ JoeCFD

      @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:sink

      More 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

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #10

      @JoeCFD got a test case and it works.
      https://github.com/zt-luo/QuickWidgetPlayer

      1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        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:sink

        Pure 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

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        How did you implement it ? Using a QQuickWidget ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        JoeCFDJ 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          How did you implement it ? Using a QQuickWidget ?

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #3

          @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 );
              }
          }
          
          SGaistS JoeCFDJ 2 Replies Last reply
          0
          • JoeCFDJ JoeCFD

            @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 );
                }
            }
            
            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @JoeCFD why did you subclass it ? The usual way is to simply use it to display your QtQuick content and then integrate the widget within another one.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @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 );
                  }
              }
              
              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #5

              @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();
              }
              
              SGaistS 1 Reply Last reply
              0
              • JoeCFDJ JoeCFD

                @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();
                }
                
                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                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.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                JoeCFDJ 1 Reply Last reply
                0
                • SGaistS SGaist

                  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.

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by JoeCFD
                  #7

                  @SGaist I tried to use QWidget as well. I need to put it somewhere in the layout of my app anyway later.

                  SGaistS 1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    @SGaist I tried to use QWidget as well. I need to put it somewhere in the layout of my app anyway later.

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @JoeCFD what happens is you only use QQuickWidget in your main function ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    JoeCFDJ 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      @JoeCFD what happens is you only use QQuickWidget in your main function ?

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by JoeCFD
                      #9

                      @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:sink

                      More 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

                      JoeCFDJ 1 Reply Last reply
                      0
                      • JoeCFDJ JoeCFD

                        @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:sink

                        More 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

                        JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by
                        #10

                        @JoeCFD got a test case and it works.
                        https://github.com/zt-luo/QuickWidgetPlayer

                        1 Reply Last reply
                        0
                        • JoeCFDJ JoeCFD has marked this topic as solved on
                        • JoeCFDJ JoeCFD referenced this topic on

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved