Important: Please read the Qt Code of Conduct -

Finally I have camera problem...

  • I need camera based on widgets for Android. All I did like in provided camera example. I even added permissions requests to manifest and Java code.
    The camera code sequence is like that (excluding connections for error and capture result):

        camera = new QCamera( QCameraInfo::defaultCamera() );
        imageCapture = new QCameraImageCapture( camera ); 
        QImageEncoderSettings codec;
        qWarning()<<"camera setting viewfinder";
        camera->setViewfinder( ui->viewFinder );
        qWarning()<<"camera setting capture mode";
        qWarning()<<"camera starting";

    Error handler is simple:

    void CameraDlg::cameraError(QCamera::Error)
        qWarning()<<"camera error:"<<camera->errorString();


    : camera setting viewfinder
    : camera setting capture mode
    : camera starting
    : camera error: "The camera service is missing"


    Qt 5.12.5 - I read similar problems were with Qt 5.4. And I read they must be solved.

  • No cameras at all...

        QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
        foreach (const QCameraInfo &cameraInfo, cameras)
            qWarning() << cameraInfo.deviceName();

    Gives nothing. :-(

  • Damn. This requires permissions for camera on mainfest and code. With them it founds "front" and "back" cameras on my device. But viewfinder is empty. And I finally found this in Qt docs:

    The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the VideoOutput and the Video QML Type.

    But what was against implement QCameraViewfinder using VideoOutput for Android? No answer...
    I will not mark this thread as solved - the solution assumes working QCameraViewfinder. But it does not.

  • Lifetime Qt Champion

    @Gourmet said in Finally I have camera problem...:

    But what was against implement QCameraViewfinder using VideoOutput for Android?

    What do you mean? One is a C++ widget the other QML component - completely different technologies. Qt Widgets are not that well suited for mobile applications, that's probably why QCameraViewfinder is not supported on Android. You should really consider to use QML for mobile applications.

    Also leaving this thread open because you want QCameraViewfinder to support Android will not help - this forum is for Qt users not Qt developers. You should file a change request in Qt bug tracker instead.

  • Bad advice. Camera and viewfinder can be made to work very well in Android and this site has many discussions about how it's done.

  • @jsulm said in Finally I have camera problem...:

    What do you mean?

    That was small mistake. I meant QOpenGLWidget but wrote about QML component.

    You should file a change request in Qt bug tracker instead.

    I have created QTBUG-80341 - immediately it have got level P2: Important. This gives hope for solution. And for same mark here. Now it's absence shows to Qt users - the problem persists yet.

Log in to reply