O'Reilly logo

Qt 5 Blueprints by Symeon Huang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required