QCamera can't be displayed in QGraphicsVideoItem



  • In the Qt Doc:Camera Overview, it's said:

    In C++, your choice depends on whether you are using widgets, or QGraphicsView. The QCameraViewfinder class is used in the widgets case, and QGraphicsVideoItem is useful for QGraphicsView.

    I want to display camere image in QGraphicsView, so I write those code:

    ...
    videoItem = new QGraphicsVideoItem;
    camera->setViewfinder(videoItem);
    videoItem->setSize(QSizeF(100, 100));
    videoItem->setPos(0, 0);
    videoItem->setAspectRatioMode(Qt::IgnoreAspectRatio);
    scene->addItem(videoItem);
    camera->setCaptureMode(QCamera::CaptureVideo);
    camera->start();
    ...
    

    but it doesn't work. And if I replace the QGraphicsVideoItem with QCameraViewfinder, it works. (Qt 5.7.0)


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Got any error printed ?


Log in to reply
 

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