Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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->setScene(scene);
        ui->graphicsView->setStyleSheet("background-color: transparent; border: none;");
        ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        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);
        timeline->start();
    

    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.

    0_1541396498763_cap1.PNG

    0_1541396511229_cap2.PNG

    0_1541396518074_cap3.PNG



  • This post is deleted!


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


  • Lifetime Qt Champion

    Hi
    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

    @R_Irudezu
    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.
    https://forum.qt.io/topic/1024/paint-over-qvideowidget/9



  • @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