Qt World Summit: Register Today!

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);
    QBoxLayout *layout = new QVBoxLayout;


    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

Log in to reply