Discussion Board

Results 1 to 14 of 14

Thread: QAccelerator

  1. #1
    Registered User EdKeens's Avatar
    Join Date
    May 2009
    Posts
    8
    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 danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    What is QAccelerator?

  3. #3
    Nokia Developer Moderator divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    Qt doesn't have such class.

  4. #4
    Registered User EdKeens's Avatar
    Join Date
    May 2009
    Posts
    8
    I'm sorry, I meant QAccelerometer.

  5. #5

  6. #6
    Registered User EdKeens's Avatar
    Join Date
    May 2009
    Posts
    8
    #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 divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    Code:
    #include <QAccelerometer>

  8. #8
    Nokia Developer Champion danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    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 EdKeens's Avatar
    Join Date
    May 2009
    Posts
    8
    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 divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    See danhicksbyron reply for the guidelines.

  11. #11
    Registered User EdKeens's Avatar
    Join Date
    May 2009
    Posts
    8
    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 divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    Add
    Code:
    QTM_USE_NAMESPACE;
    somewhere around includes.

  13. #13
    Registered User EdKeens's Avatar
    Join Date
    May 2009
    Posts
    8
    Thanks a lot Divanov, it worked

  14. #14
    Nokia Developer Moderator divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved