We have learned how to connect to our camera using Qt's multimedia module in the previous section. Now, we will try and capture a still image from the camera and save it into a JPEG file. It's actually very very simple with Qt.
First, open mainwindow.h and add the following variable:
private: Ui::MainWindow *ui; QCamera* camera; QCameraViewfinder* viewfinder; QCameraImageCapture* imageCapture; bool connected;
Then, right-click on the Capture button in mainwindow.ui and select Go to slot.... Then, select clicked() and press OK. Now, a new slot function will be created for you in mainwindow.cpp. Add the following code to capture an image from the camera:
void MainWindow::on_captureButton_clicked() { if (connected) { imageCapture = new QCameraImageCapture(camera); camera->setCaptureMode...