×

Discussion Board

Results 1 to 14 of 14

Thread: QAccelerator

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    8

    QAccelerator

    Hello,
    I'm kinda new to QT, but I do understand basics.
    I'd like to know how to use QAccelerator class, what files are needed to include and if there's anything special to be written in .pro file. In my atempts to use QAccelerator, I always get error that QAccelerator was not declared in this scope, even though i included QAccelerator class, and header file.
    Thanks for Your help in advance

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: QAccelerator

    What is QAccelerator?

  3. #3
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QAccelerator

    Qt doesn't have such class.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    8

    Re: QAccelerator

    I'm sorry, I meant QAccelerometer.

  5. #5

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    8

    Re: QAccelerator

    #include <QtGui/QApplication>
    #include "mainwindow.h"
    #include <QSensor>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    #if defined(Q_WS_S60)
    w.showMaximized();
    #else
    w.show();
    #endif
    QAccelerometer *sensor = new QAccelerometer(this);
    QSensor sensor("QAccelerometer");
    sensor.start();
    return a.exec();
    }


    this code gives me error "'QAccelerometer' was not declared in this scope"

  7. #7
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QAccelerator

    Code:
    #include <QAccelerometer>

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: QAccelerator

    And also, in the pro file:
    Code:
    CONFIG += mobility
    MOBILITY += sensors
    (If I'm remembering it correctly)
    Last edited by divanov; 2010-07-17 at 10:13. Reason: fixing the case

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    8

    Re: QAccelerator

    Now it gives me error QSensor: No such file or directory, and the same with QAccelerometer, and i have Nokia QT SDK installed.

  10. #10
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QAccelerator

    See danhicksbyron reply for the guidelines.

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    8

    Re: QAccelerator

    Ok, even when I add
    Code:
     CONFIG += mobility
    MOBILITY += sensors
    to pro file, and include QAccelerometer and QSensor classes, I always get error "'QAccelerometer was not declared in this scope'".

  12. #12
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QAccelerator

    Add
    Code:
    QTM_USE_NAMESPACE;
    somewhere around includes.

  13. #13
    Registered User
    Join Date
    May 2009
    Posts
    8

    Re: QAccelerator

    Thanks a lot Divanov, it worked

  14. #14
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QAccelerator

    There are examples for Qt Mobility. You might find them worth of interest
    http://qt.gitorious.org/qt-mobility/...aster/examples

Posting Permissions

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