Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Paint over QVideoWidget
Forum Updated to NodeBB v4.3 + New Features

Paint over QVideoWidget

Scheduled Pinned Locked Moved Mobile and Embedded
9 Posts 4 Posters 13.9k Views 2 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.
  • B Offline
    B Offline
    borut123
    wrote on last edited by
    #1

    Symbian/Maemo phones, Qt 4.6.3.

    I use QMediaPlayer for playing and QVideoWidget for displaying streaming video.

    Now I'm trying to display some additional info over the video, for example video title, duration etc.
    Is it somehow possible to put other widgets or paint on top of the QVideoWidget?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      Since QVideoWidget inherits QWidget, you could just add another QWidget as its child, set position where you want and control opacity etc. The childWidget will appear on top of the video widget.

      @
      QWidget *childWidget = new QWidget(videoWidget);
      @

      1 Reply Last reply
      0
      • B Offline
        B Offline
        borut123
        wrote on last edited by
        #3

        I've tried this code:

        @
        QPushButton *btn = new QPushButton(videoWidget);
        btn->setText("Button test" ) ;
        btn->setVisible(true);
        @

        But unfortunatelly button is still not displayed

        [edit: fixed @ / chetankjain]

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          Ok, I need to build my Qt with Phonon support, but tried this quickly to check if this would work:
          @
          QPushButton *btn = new QPushButton(ui->label);
          btn->setText("click me");
          btn->setGeometry(5,5,20,20); // wrt the parent label
          btn->setVisible(true);
          qDebug() << btn->geometry();
          @
          and it does ... but have to fix my env first and try this with QVideoWidget. I still think it should work... qDebug can chk if the geometry is right.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kkrzewniak
            wrote on last edited by
            #5

            Have You tried sub-classing QVideoWidget and implementing a paintEvent like so:

            @--
            void YourClass::paintEvent(QPaintEvent* e)
            {
            QVideoWidget::paintEvent(e);
            QPainter painter(this);
            //... painting what you need over the content rendered by QVideoWidgets paintEvent
            }
            @

            Me, Grimlock, not "nice dino". ME BASH BRAINS!

            1 Reply Last reply
            0
            • W Offline
              W Offline
              witsku
              wrote on last edited by
              #6

              Try using top-level-widgets (no parent) as overlays.
              That should work since those have own native window.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                borut123
                wrote on last edited by
                #7

                toplevelwidget dialog on N900 blurs the screen, video motion is not seen.
                toplevelwidget PushButton is displayed below video, even though it should be on the top.

                I've also tried to subclass QVideoWidget, but paintEvent method of new class is not called at all
                during app running. This is strange, probably my mistake somewhere in the code.

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  borut123
                  wrote on last edited by
                  #8

                  I guess we'll have to wait till Qt 4.7 comes to Symbian,and hope it fixes the issue with video overlay.

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rafaelgm
                    wrote on last edited by
                    #9

                    I know it's an old thread (4 years), but others may find it through a search engine, like I did, trying to find a solution.

                    What worked for me was to do this:

                    Instead of using QVideoWidget, use a QGraphicsView:

                    Create a sub-class of QGraphicsView (say, MyGraphicsView)

                    Create a QGraphicsScene, adding to the graphics view (setScene)

                    Create a QGraphicsVideoItem and add it to your scene (addItem)

                    Set the player output to the graphics video created on step 3

                    Override paintEvent on your subclass and do your drawing

                    Here is some sample code:
                    @MyGraphicsView *view = new MyGraphicsView(this);
                    QGraphicsScene *scene = new QGraphicsScene(view);
                    QGraphicsVideoItem *item = new QGraphicsVideoItem();
                    view->setScene(scene);
                    scene->addItem(item);
                    player->setVideoOutput(item);@
                    Now, for the paintEvent:
                    @void MyGraphicsView::paintEvent(QPaintEvent *e)
                    {
                    QGraphicsView::paintEvent(e);
                    QPainter painter(this->viewport());

                    // Do your drawing.
                    // For e.g., draw a rectangle:
                    painter.setPen(Qt::black);
                    painter.drawRect(10, 10, 200, 200);
                    

                    }@

                    1 Reply Last reply
                    1

                    • Login

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