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

Problem resizing QGraphicsVideoItem / QGraphicsScene



  • Hi there...
    I'm creating my own app to play different videos in parallel. I've started using Qt example "videographicsitem" and so my code looks like this:
    @
    videoItem = new QGraphicsVideoItem;

    QGraphicsScene *scene = new QGraphicsScene(this);
    QGraphicsView *graphicsView = new QGraphicsView(scene);
    scene->addItem(videoItem);
    
    QBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(graphicsView);
    setLayout(layout);
    mediaPlayer.setVideoOutput(videoItem);
    

    @

    Ok, so I have to resize my graphicsview using mouse preserving aspectrazio and this works very well using this code:
    @
    QGraphicsView *view = NULL;

    view = this->findChild<QGraphicsView*>("graphView");
    view->fitInView(videoItem, Qt::KeepAspectRatio);
    

    @
    in the resizeEvent of VideoPlayer's parent.
    My problem is that code above doesn't do nothing if I just put VideoPlayer widget (using setGeometry); video inside is not fit and I have to resize with mouse to get video fitted.

    Someone knows how I can properly fit video just setting dimension with setGeometry()?

    thanks in advance
    Gianni


Log in to reply