Qt World Summit: Register Today!

QGraphicsScene is not working on player widget?

  • I'll try explain the problem as much as i can.

    First of all, i have a QGraphicsScene item with animated:

        timeline = new QTimeLine;
        timeline->setDuration (3000);
        timeline->setCurveShape (QTimeLine::CosineCurve);
        QObject::connect (timeline, SIGNAL(finished()), timeline, SLOT(deleteLater()));
        scene = new QGraphicsScene(ui->playerWidget);   
        ui->graphicsView->setStyleSheet("background-color: transparent; border: none;");
        ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff );
        scene->setSceneRect (-60, -60, 150, 150);
        setupRot (timeline, scene->addEllipse (rect (50), QPen (QBrush (QColor (0, 153, 255)), 4, Qt::DotLine)));
        scene->addEllipse (rect (45), QPen (QBrush (QColor ("grey")), 4));
        timeline->setLoopCount (0);

    this plays a circular shape with infinite loop. I want to show this on player widget, the player widget is:

        // I dragged and dropped a widget in UI named "playerWidget" 
        player = new QMediaPlayer(this);
        videoWidget = new QVideoWidget(ui->playerWidget); 

    The problem is (or my blindness), this graphic scene is working on a dragged and dropped widget but not working on playerWidget, i don't know why.

    By the way, playerWidget is playing an RTSP stream.




  • This post is deleted!

  • up ↑ what's may cause the problem...

  • Lifetime Qt Champion

    Im not sure what issue really is.
    However, if you mean when you drag a widget
    to the playing video and widget is no longer shown, its mostly due
    to the video being an overlay so it will always be in front.

  • @mrjj exactly this is, so this graphicsScene layer is behind the player. So is there anyway to show graphicsScene widget in front of the playerWidget?

  • Lifetime Qt Champion

    On windows, i think no. At least i had no success.
    However, it seems you can subclass and add a paintEvent to draw what you want.

  • @mrjj If possible, can you show me a simple example with referencing to my first message above.
    By the way. is it possible to set a new transparent widget or label over playerWidget then draw on it. I tried but didn't get success.

Log in to reply