×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Using QCamera

  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Using QCamera

    So I checked the mobility APIs documentation and found this
    camera = new QCamera;
    viewFinder = new QCameraViewfinder();
    viewFinder->show();

    camera->setViewfinder(viewFinder);

    imageCapture = new QCameraImageCapture(camera);

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

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

    ...

    //on shutter button pressed
    imageCapture->capture();

    //on shutter button released
    camera->unlock();
    But whereever I put this code in new project I get bunch of errors. I already added multimedia modules to project file and included QCamera.
    I never used Qt before, so this all is very confusing.
    Is there any example of just having viewfinder and ability to snap a photo with QCamera? I saw one but that had a lot more code than I need and was very confusing, I'm not too good at reading C++.

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Using QCamera

    Note, that you need Qt Mobility 1.1 or later to have Camera API.

  3. #3
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Re: Using QCamera

    I have it all, I downloaded latest Qt SDK Tech Preview which got it.

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Using QCamera

    CONFIG += mobility
    MOBILITY += multimedia
    ?
    QTM_USE_NAMESPACE
    ?

  5. #5
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Re: Using QCamera

    I didn't have QTM_USE_NAMESPACE, but still got errors after adding that.
    I shortened all a bit, so main.cpp is
    Code:
    #include <QtGui/QApplication>
    #include "mainwindow.h"
    
    #include <QCamera>
    QTM_USE_NAMESPACE
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        camera = new QCamera;
    #if defined(Q_WS_S60)
        w.showMaximized();
    #else
        w.show();
    #endif
    
        return a.exec();
    }
    And yet I got
    C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:5: error: 'QtMobility' is not a namespace-name
    C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:5: error: expected namespace-name before ';' token
    C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:-1: In function 'int qMain(int, char**)':
    C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:11: error: 'camera' was not declared in this scope

  6. #6
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Using QCamera

    QTM_USE_NAMESPACE
    #include <QCamera>

  7. #7
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Re: Using QCamera

    That caused even more errors.
    Most likely because according to http://doc.qt.nokia.com/qtmobility-1.2/multimedia.html
    No Special Namespace

    Unlike the other APIs in Qt Mobility, the Multimedia API is not in the QtMobility namespace.
    I don't need that namespace thing in this case, after removing it I got only 2 build issues
    C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:-1: In function 'int qMain(int, char**)':
    C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:10: error: 'camera' was not declared in this scope

  8. #8
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Using QCamera

    Well, in your code variable camera is indeed not defined anywhere.

  9. #9
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Re: Using QCamera

    So how or like what should I define it :/
    QCamera doesn't seem to be int, float or whatever

  10. #10
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Using QCamera

    It's a QCamera.

  11. #11
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Re: Using QCamera

    Can't you just give me line or 2?

    Code:
    QCamera camera;
    camera = new QCamera;
    Now with this I get
    C:/QtSDK/proj/untitled-build-simulator/../../Simulator/QtMobility/mingw/include/QtMultimediaKit/qcamera.h:199: error: 'QCamera& QCamera:perator=(const QCamera&)' is private
    C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:18: error: within this context

  12. #12
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Using QCamera

    Try "QCamera* camera;"

    When you do a "new" of "Object" you create an "Object*".

    (This is pretty basic C++ stuff -- you need to get yourself a C++ book and work through some of the examples before you go playing with more complicated things.)

  13. #13
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Re: Using QCamera

    Got it working so far, thanks.
    Well, I tried guide from cplusplus.com while ago, basic syntax was easy but ome stuff like pointers and all that got confusing. That's probably because I used Python before, it just lacked feature/constant updated/support from Nokia.

    By the way any continuation of code like
    Code:
    camera->setCaptureMode(QCamera::CaptureStillImage);
    gives C:/QtSDK/proj/untitled-build-simulator/../untitled/main.cpp:29: error: expected constructor, destructor, or type conversion before '->' token
    Any idea about this one?
    Last edited by Arvis17; 2011-01-21 at 21:46.

  14. #14
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Using QCamera

    Well, until you understand pointers you're going to be hopelessly lost.

  15. #15
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    56

    Re: Using QCamera

    I do understand them,
    & - points at something's memory address
    * - give value pointed by specific memory address
    Right?
    So now I don't see much I could do with the code I posted there, besides that is from QCamera doc's so why wouldn't it work.

Similar Threads

  1. Qt QCamera example didn't autofocus
    By stone.chao in forum [Archived] Qt Mobility Project
    Replies: 10
    Last Post: 2011-11-16, 14:36
  2. Replies: 7
    Last Post: 2011-01-26, 00:13
  3. QCamera is missing from QtMobility SDK
    By rami75lu in forum [Archived] Qt Mobility Project
    Replies: 7
    Last Post: 2010-12-05, 11:26
  4. Does Qt Mobility 1.0.0 support QCamera for N900?
    By hpbrother in forum [Archived] Qt Mobility Project
    Replies: 9
    Last Post: 2010-05-19, 11:18
  5. grab Frame/Image using QCamera
    By AcidJunkie in forum [Archived] Qt Mobility Project
    Replies: 4
    Last Post: 2010-05-03, 19:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×