Qcamera for android



  • Hello, everyone.

    I have trouble in using qcamera for an android app.

    in the GUI, I use a horizontal layout: hlayout. then the code is:

    ui->setupUi(this);

    this->camera = new QCamera(this);
    this->viewfinder = new QCameraViewfinder(this);
    ui->hlayout->addWidget(viewfinder);
    camera->setCaptureMode(QCamera::CaptureStillImage);
    camera->setViewfinder(viewfinder);
    camera->start();
    cout<<"camera status:"<<this->camera->status()<<"#"<<endl;
    this->camera->status();//I do not know how to use this status, because it can not be printed
    camera->availability();//I do not know how to use this status, because it can not be printed

    When the app starts, the android system does tip me that this app wants the camera, but nothing is displayed in the hlayout.

    What is the situation now?

    Thanks in advance.


  • Lifetime Qt Champion

    Hi,

    You should also add which version of Qt you are using. IIRC, painting the camera on widget was not supported (I don't know the state for 5.4) However QML can be used to interact with the camera.



  • Thanks for you kindly reply.

    The QT version I use is:5.3.1

    Is there any example to show how to show the camera on a widget?

    and also examples to interact with the camera by QML?

    [quote author="SGaist" date="1409397873"]Hi,

    You should also add which version of Qt you are using. IIRC, painting the camera on widget was not supported (I don't know the state for 5.4) However QML can be used to interact with the camera.[/quote]


  • Lifetime Qt Champion

    Like I wrote, AFAIK, the QCamera class is not usable as is with QWidget on Android with that version of Qt. One thing to do is check with the latest 5.4 testing package to see whether it improves.

    You have the camera examples in Qt's documentation that you can use for that.



  • to print the status of camera, follow this:

     connect(camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(statusChanged(QCamera::Status)));
    

    and then deal with it in your own function statusChanged(QCamera::Status status).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.