Book Image

QT5 Blueprints

By : Symeon Huang
Book Image

QT5 Blueprints

By: Symeon Huang

Overview of this book

Table of Contents (17 chapters)
Qt 5 Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using QFileDialog


The last step of taking a photo is to save it to disk. At this point, the program saves an image to the file, but the location is determined by the camera backend. We can simply use a dialog, letting the user choose the directory and the filename of the photo. There is a QFileDialog class to help make the work easier. The easiest way to create a QFileDialog class is to use the static functions. Therefore, edit the onCaptureButtonClicked function in the mainwindow.cpp file.

void MainWindow::onCaptureButtonClicked()
{
  imgCapture = new QCameraImageCapture(camera, this);
  connect(imgCapture, static_cast<void (QCameraImageCapture::*) (int, QCameraImageCapture::Error, const QString &)>(&QCameraImageCapture::error), this, &MainWindow::onImageCaptureError);
  connect(imgCapture, &QCameraImageCapture::imageCaptured, this, &MainWindow::onImageCaptured);

  camera->searchAndLock();
  imgCapture->setCaptureDestination(QCameraImageCapture::CaptureToFile...