I am trying to show the one camera output on two QLabel widget. However I am not able to do so. I encounter following error.
Graph failed to connect filters -2147024809
However I can see it on one screen not on another. If this is a wrong approach or is it not possible at all?
cM = new QCamera(this);
cM2 = new QCamera(this);
cV = new QCameraViewfinder(this);
cV2 = new QCameraViewfinder(this);
mMenu = new QMenu("Options",this);
cA = new QAction("one camera", this);
cA2 = new QAction("both camera", this);
mMenu->addActions({cA, cA2});
ui->pushButton->setMenu(mMenu);
cM->setViewfinder(cV);
cM2->setViewfinder(cV2);
cBox1 = new QVBoxLayout();
cBox2 = new QVBoxLayout();
cBox1->addWidget(cV);
cBox2->addWidget(cV2);
ui->label->setLayout(cBox1);
ui->label_2->setLayout(cBox2);
connect(cA, &QAction::triggered, [&](){
cM->start();
cM2->start();
You need to construct yoru cameras with cameraInfo, otherwise it's not bound to real hardware. https://doc.qt.io/qt-5/qcamera.html
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras)
{
if (cameraInfo.deviceName() == "mycamera")
camera = new QCamera(cameraInfo, this);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.