[Interest] QCamera flash modes

Lopes Yoann Yoann.Lopes at theqtcompany.com
Thu Jul 23 12:39:55 CEST 2015

On 22 Jul 2015, at 22:41, Jason H <jhihn at gmx.com<mailto:jhihn at gmx.com>> wrote:

This is not working.

So In QML, I start the backface camera, and it grabs viewfinder frames.
I then call my C++ object which has this function:
bool FlashControl::isFlashSupported(){
camera = new QCamera(QCamera::BackFace);
if (camera) {
QCameraExposure *exp = camera->exposure();
if (exp) {
qDebug() << "QCamera ok, returning flash modes"
<< exp->isFlashModeSupported(QCameraExposure::FlashOn)
<< exp->isFlashModeSupported(QCameraExposure::FlashAuto)
<< exp->isFlashModeSupported(QCameraExposure::FlashManual);

return exp->isFlashModeSupported(QCameraExposure::FlashOn);
else qDebug() << "has QCamera, no exp";
} else qDebug() << "no QCamera";
return false;

Which then prints all falses and returns false itself, even on a camera that has a working flash (Nexus6). What am I still doing wrong?

Having the QML Camera started doesn’t mean your C++ QCamera is started. They are two independent objects.

You need to call camera->start(). However, it’s not going to work if the camera is already started from the QML side, you need to do the check before starting the camera in QML. Another possibility is to pass the QML camera object to your C++ backend, and retrieve the actual QCamera object being in use:

void SomeClass:setQMLCamera(QObject *qmlCamera)
    QCamera *camera = qvariant_cast<QCamera *>(qmlCamera->property(“mediaObject”));



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150723/c22eabb8/attachment.html>

More information about the Interest mailing list