Answer the question
In order to leave comments, you need to log in
How to make friends QCamera and QGraphicsVideoItem?
There is a code:
#include <QtMultimediaWidgets>
int main(int argc, char *argv[])
{
QApplication * app = new QApplication(argc,argv);
QGraphicsView * view = new QGraphicsView();
QGraphicsScene * scene = new QGraphicsScene();
QGraphicsVideoItem * item = new QGraphicsVideoItem();
view->setScene(scene);
scene->addItem(item);
view->show();
QCamera * camera;
if(QCamera::availableDevices().count() > 0)
{
camera = new QCamera();
camera->setViewfinder(item);
camera->start();
}
return app->exec();
}
no video surface, cant start
Camera state changed: QCamera::LoadedState
Answer the question
In order to leave comments, you need to log in
I have the same. If you are urgent, then until they fix it, you can do this:
#include <QtGui/QtGui>
#include <QtWidgets/QtWidgets>
#include <QtMultimediaWidgets/QtMultimediaWidgets>
int main(int argc, char *argv[]) {
QApplication *app = new QApplication(argc,argv);
QGraphicsView *view = new QGraphicsView();
QGraphicsScene *scene = new QGraphicsScene();
QVideoWidget *widget = new QVideoWidget();
view->setScene(scene);
scene->addWidget(widget);
view->show();
QCamera *camera;
if(QCamera::availableDevices().count() > 0) {
camera = new QCamera();
camera->setViewfinder(widget);
camera->start();
}
return app->exec();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question