Important: Please read the Qt Code of Conduct -

QCameraImageCapture resource error on imageSave

  • I'm currently trying to capture a still image with a QCamera Widget, but whenever i try to run the capture() function of QCameraImageCapture, it errors and gives me a QCameraImageCapture::ResourceError "Could not save image to file."

    Ive tried my hardest to copy directly from the QCamera example from QT, whilst cutting out the video recording part of it as i only need still images.

    This is my widget's constructor

    	connect(saveImageButton, SIGNAL(pressed()), this, SLOT(saveImagePressed()));
    	if (!checkCameraAvailability()) close();
    	QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
    	QPalette p = palette();
    	p.setBrush(QPalette::Highlight, QBrush(Qt::white));
    	p.setBrush(QPalette::HighlightedText, QBrush(Qt::black));
    	foreach(const QCameraInfo &ci, cameras) {
    		QCheckBox *cam = new QCheckBox(ci.description());
    		QListWidgetItem *lwi = new QListWidgetItem();
    		availableCameras->setItemWidget(lwi, cam);
    	m_camera.reset(new QCamera(QCameraInfo::availableCameras()[0]));
    	connect(, QOverload<QCamera::Error>::of(&QCamera::error), this, &WebCamDialog::displayCameraError);
    	m_camera->viewfinderSettings().setResolution(QSize(400, 400));
    	qDebug() << m_camera->viewfinderSettings().resolution();
    	m_imageCapture.reset(new QCameraImageCapture(;
    	connect(, QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error),
    		this, &WebCamDialog::displayCaptureError);
    	connect(, SIGNAL(imageCaptured(int, const QImage)), this, SLOT(imageCaptured(int, const QImage)));
    	connect(, SIGNAL(imageSaved(int, const QString)), this, SLOT(imageSaved(int, const QString)));

    this is my capture function when a button is pressed

    void WebCamDialog::saveImagePressed() {
    	qDebug() << m_imageCapture->isReadyForCapture();
    	qDebug() << m_camera->lockStatus() << m_imageCapture->isReadyForCapture();

    the above qDebug returns true, QCamera::Unlocked, true

    these are my imageSaved, imageCaptured, and error functions

    void WebCamDialog::imageCaptured(int id, const QImage &i) {
    	QLabel *im = new QLabel();
    void WebCamDialog::imageSaved(int id, const QString &s) {
    	qDebug() << s;
    void WebCamDialog::displayCaptureError(int id, QCameraImageCapture::Error error, const QString &errorString) {
    	qDebug() << error;
    	qDebug() << tr("Image Capture Error") << errorString;

    imageCaptured displays the captured image correctly, imageSaved is never reached. I only have one camera available so i've ommited the actual selecting of a camera, and just made it default to the only camera i have

  • Try adding m_imageCapture.setCaptureDestination(QCameraImageCapture::CaptureToFile);.


    QCheckBox *cam = new QCheckBox(ci.description());
    vailableCameras->setItemWidget(lwi, cam);

    Hurts my feelings. See it applies also to QListWidgetItem with the only difference that you don't, obviously, specify a column