Play videos on graphicsview.(on Qt5 form graphics view)



  • I am using Qt5 with C++ in Windows7 . Can any one tell how to play videos on form widget (graphicsview).I got the proper out put with QVideowidget.But for my application i need play videos on form . I tryed this code form Qt documentation but i got errors
    player = new QMediaPlayer(this);

    QGraphicsVideoItem *item = new QGraphicsVideoItem;
    player->setVideoOutput(item);
    graphicsView->scene()->addItem(item);
    graphicsView->show();

    player->setMedia(QUrl("http://example.com/myclip4.ogv"));
    player->play();

    Error: graphicsView not declared in this scope.
    if i write in the place of graphic view as ui->graphicsView->scene()->additem(item); , my Qt compiler stop working and suddenly stoped .



  • I had the same problem.
    What I have done is to initialize the scene object.
    QGraphicsScene *scene=new=new QGraphicScene();


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.