View Single Post
Posts: 395 | Thanked: 509 times | Joined on Jan 2011 @ Brisbane, Australia
#1
Not sure what I'm doing wrong, I've used signals/slots before, but it doesn't seem to fire for me on this.

Trying to figure out how all the QCamera stuff works, so first step would be taking a picture and saving it to file.

If anyone would have a clue as to why the imageSaved() isn't firing (I've tried it on a bunch of different signals, tried it with the QCamera::Status and State, it never gets fired for whatever I set it as).

Qt documentation isn't much help, their example they give explains nothing, doesn't tell you how the file is saved (if at all), if at all or where to set the file location or names (or I've just missed it).

Code:
private slots:
    void on_pushButton_clicked();
    void cap(int par1, QString par2);
Code:
void MainWindow::on_pushButton_clicked()
{
    QCamera *camera = new QCamera(QCamera::availableDevices().at(0));
    //QCameraViewfinder *viewFinder = new QCameraViewfinder;
    //camera->setViewfinder(viewFinder);
    //viewFinder->show();

    imageCapture = new QCameraImageCapture(camera);
    connect(imageCapture, SIGNAL(imageSaved(int,QString)), this, SLOT(cap(int,QString)));
    imageCapture->setCaptureDestination(QCameraImageCapture::CaptureToFile);

    QImageEncoderSettings imageSettings;
    imageSettings.setCodec("image/jpeg");
    imageSettings.setResolution(640, 480);
    qDebug() << imageSettings.resolution();

    imageCapture->setEncodingSettings(imageSettings);

    camera->setCaptureMode(QCamera::CaptureStillImage);
    camera->start();

    //on half pressed shutter button
    camera->searchAndLock();

    //connect(imageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(cap(int,QImage)));
    //on shutter button pressed
    imageCapture->capture();

    //on shutter button released
    camera->unlock();

    qDebug() << "done";
}

void MainWindow::cap(int par1, QString par2){
    qDebug() << "captured";
}