QT 6.7 and camera dialog issues
-
I am trying to display a dialog with a camera when a button is pressed, but the program keeps crashing when I attempt to start the camera in the constructor of the dialog class. What am I doing wrong? I am using QTcreator. The image below is what I see if I comment out the camera->start() line.
The classes for the widget and dialog are below:
widget + dialog
#include "item_w.h" #include "ui_item_w.h" item_w::item_w(QWidget *parent) : QWidget(parent) , ui(new Ui::item_w) { ui->setupUi(this); } item_w::~item_w() { delete ui; } void item_w::on_cam_img_btn_clicked() { /* captureSession.setCamera(camera); viewfinder->show(); captureSession.setVideoOutput(viewfinder); captureSession.setImageCapture(imageCapture); camera->start(); imageCapture->capture(); */ cameraDialog *cDiag = new cameraDialog; cDiag->show(); } #include "cameradialog.h" #include "ui_cameradialog.h" cameraDialog::cameraDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::cameraDialog) { ui->setupUi(this); captureSession.setCamera(camera); captureSession.setVideoOutput(ui->widget_camera_area); ui->widget_camera_area->show(); qDebug(); camera->start(); } cameraDialog::~cameraDialog() { camera->stop(); delete camera; delete ui; }
-
I am trying to display a dialog with a camera when a button is pressed, but the program keeps crashing when I attempt to start the camera in the constructor of the dialog class. What am I doing wrong? I am using QTcreator. The image below is what I see if I comment out the camera->start() line.
The classes for the widget and dialog are below:
widget + dialog
#include "item_w.h" #include "ui_item_w.h" item_w::item_w(QWidget *parent) : QWidget(parent) , ui(new Ui::item_w) { ui->setupUi(this); } item_w::~item_w() { delete ui; } void item_w::on_cam_img_btn_clicked() { /* captureSession.setCamera(camera); viewfinder->show(); captureSession.setVideoOutput(viewfinder); captureSession.setImageCapture(imageCapture); camera->start(); imageCapture->capture(); */ cameraDialog *cDiag = new cameraDialog; cDiag->show(); } #include "cameradialog.h" #include "ui_cameradialog.h" cameraDialog::cameraDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::cameraDialog) { ui->setupUi(this); captureSession.setCamera(camera); captureSession.setVideoOutput(ui->widget_camera_area); ui->widget_camera_area->show(); qDebug(); camera->start(); } cameraDialog::~cameraDialog() { camera->stop(); delete camera; delete ui; }
@he_R0 said in QT 6.7 and camera dialog issues:
camera->start();
Where do you initialize this pointer?
ui->widget_camera_area->show();
Why? This is not needed at all.
-
@he_R0 said in QT 6.7 and camera dialog issues:
camera->start();
Where do you initialize this pointer?
ui->widget_camera_area->show();
Why? This is not needed at all.
Hello. The problem was with pointer initialization.
ui->widget_camera_area->show();
I removed this after correcting the pointer initialization in the file. Thanks
-
-
-