Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT 6.7 and camera dialog issues
Qt 6.11 is out! See what's new in the release blog

QT 6.7 and camera dialog issues

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 359 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    he_R0
    wrote on last edited by he_R0
    #1

    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;
    }
    
    

    Selection_068.png

    Christian EhrlicherC 1 Reply Last reply
    0
    • H he_R0

      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;
      }
      
      

      Selection_068.png

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      H 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @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.

        H Offline
        H Offline
        he_R0
        wrote on last edited by he_R0
        #3

        @Christian-Ehrlicher

        Hello. The problem was with pointer initialization.

        ui->widget_camera_area->show();

        I removed this after correcting the pointer initialization in the file. Thanks

        1 Reply Last reply
        0
        • H he_R0 has marked this topic as solved on
        • H he_R0 has marked this topic as unsolved on
        • H he_R0 has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved