Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Symbian Project Errors when Mobility Added



  • I have created a Symbian project that compiles and runs flawlessly on my C7. However, I wanted to add the QOrientationSensor to the project so I could tell when to reformat the screen by signals from the sensors.

    my current .pro file :
    @
    QT += declarative network webkit
    CONFIG += qt mobility threads exceptions
    MOBILITY += sensors

    folder_01.source = qml
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01

    QML_IMPORT_PATH =

    symbian:TARGET.UID3 = 0xE6DE572B

    Setup capabilities on Symbian

    symbian:TARGET.CAPABILITY +=
    LocalServices
    ReadUserData
    WriteUserData
    NetworkServices
    UserEnvironment
    Location
    ReadDeviceData

    HEADERS += wwvsource.h noaasource.h
    orientation.h

    SOURCES += main.cpp
    orientation.cpp

    include(qmlapplicationviewer/qmlapplicationviewer.pri)
    qtcAddDeployment()

    maemo5|maemo6 {
    OTHER_FILES +=
    qtc_packaging/debian_fremantle/rules
    qtc_packaging/debian_fremantle/README
    qtc_packaging/debian_fremantle/copyright
    qtc_packaging/debian_fremantle/control
    qtc_packaging/debian_fremantle/compat
    qtc_packaging/debian_fremantle/changelog
    }

    OTHER_FILES +=
    qml/images/aindexscale.svg
    qml/images/glass.svg
    qml/images/kindexscale.svg
    qml/images/led-green.svg
    qml/images/led-red.svg
    qml/images/led-yel.svg
    qml/images/lineedit.svg
    qml/images/lineedit.sci
    qml/images/needle.svg
    qml/images/needle_shadow.svg
    qml/images/sfiscale-max.svg
    qml/images/sfiscale.svg
    qml/images/shadow.svg
    qml/images/spinner-bg.svg
    qml/images/spinner-select.png
    qml/images/stripes.svg
    @

    I am attempting to add the *Screen orientation detection for QML * from
    Chris' Blog - cdumez.blogspot.com/2010/12/screen-orientation-detection-for-qml.html

    The result is errors that indicate QtMobility is not in the namespace even though I have used the QTM_USE_NAMESPACE macro and mobility global header.

    Here are the errors from QtCreator:

    @
    ../SolStats/orientation.cpp:3:1: error: ‘QtMobility’ is not a namespace-name
    ../SolStats/orientation.cpp:3:1: error: expected namespace-name before ‘;’ token
    ../SolStats/orientation.cpp: In constructor ‘Orientation::Orientation(QObject*)’:
    ../SolStats/orientation.cpp:10:18: error: expected type-specifier before ‘QOrientationSensor’
    ../SolStats/orientation.cpp:10:18: error: cannot convert ‘int*’ to ‘QtMobility::QOrientationSensor*’ in assignment
    ../SolStats/orientation.cpp:10:18: error: expected ‘;’ before ‘QOrientationSensor’
    ../SolStats/orientation.cpp:11:71: error: no matching function for call to ‘Orientation::connect(QtMobility::QOrientationSensor*&, const char [18], const char [20])’
    ../../../QtSDK/Simulator/Qt/gcc/include/QtCore/qobject.h:198:17: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
    ../../../QtSDK/Simulator/Qt/gcc/include/QtCore/qobject.h:313:13: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
    ../SolStats/orientation.cpp:12:11: error: invalid use of incomplete type ‘struct QtMobility::QOrientationSensor’
    ../SolStats/orientation.h:7:7: error: forward declaration of ‘struct QtMobility::QOrientationSensor’
    ../SolStats/orientation.cpp: In destructor ‘virtual Orientation::~Orientation()’:
    ../SolStats/orientation.cpp:16:10: warning: possible problem detected in invocation of delete operator:
    ../SolStats/orientation.cpp:16:10: warning: invalid use of incomplete type ‘struct QtMobility::QOrientationSensor’
    ../SolStats/orientation.h:7:7: warning: forward declaration of ‘struct QtMobility::QOrientationSensor’
    ../SolStats/orientation.cpp:16:10: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
    ../SolStats/orientation.cpp: In member function ‘void Orientation::onReadingChanged()’:
    ../SolStats/orientation.cpp:21:3: error: ‘QOrientationReading’ was not declared in this scope
    ../SolStats/orientation.cpp:21:24: error: ‘reading’ was not declared in this scope
    ../SolStats/orientation.cpp:21:42: error: invalid use of incomplete type ‘struct QtMobility::QOrientationSensor’
    ../SolStats/orientation.h:7:7: error: forward declaration of ‘struct QtMobility::QOrientationSensor’
    ../SolStats/orientation.cpp:24:8: error: ‘QOrientationReading’ is not a class or namespace
    ../SolStats/orientation.cpp:28:8: error: ‘QOrientationReading’ is not a class or namespace
    ../SolStats/orientation.cpp:32:8: error: ‘QOrientationReading’ is not a class or namespace
    ../SolStats/orientation.cpp:36:8: error: ‘QOrientationReading’ is not a class or namespace
    @

    Mobility libs are in the path of the project.
    Can someone point me in the right direction?

    Environment is:
    Ubuntu 11.04
    KERNEL 2.6.38.10-generic
    GNOME 2.32.1

    latest update of Qt SDK 1.2 as of 14 July 2011

    P.S. same results with WinXP QtSDK as well.



  • Hey ad5xj,
    your .pro file looks fine (as in, looks like the one I use and works).

    In Ubuntu, are you using the Remote compiler for symbian?

    How did you install QtMobility? Following this:
    https://projects.developer.nokia.com/QtM12bSymb/wiki/InstallationGuide ?

    I'd say your problem is either on the sdk/mobilit installation or on your actual code.



  • The QtMobility module was installed by the SDK maintainer. I did not install it manually either on Linux or WinXP.

    I can find no reason - code wise - why I should be getting this error.

    The QTM_USE_NAMESPACE macro should resolve this kind of thing but it does not.

    On Linux I do not use the remote compiler. I used the gcc compiler for the simulator which should work. On WinXP I use mingw.



  • Ah ok. Yes, it should work fine on the simulator.
    Are your orientation.[cpp,h] the same from the ones in the chris's blog post? There he's not using QTM_USE_NAMESPACE because he's explicitly using "QtMobility::"
    The QTM_USE_NAMESPACE macro is only defined as "using namespace QtMobility;"



  • Found the problem.

    #include <QOrientationSensor>
    #include <orientation.h>

    have to come before the QTM_USE_NAMESPACE macro to work. Thanks for the help everyone.



  • Well it looks like I spoke too soon. Now the compiler indicates the macro does not name a type:

    @
    ..\SolStats\orientation.cpp:1:30: error: QOrientationSensor: No such file or directory
    ..\SolStats\orientation.cpp:3: error: 'QTM_USE_NAMESPACE' does not name a type
    ..\SolStats\orientation.cpp: In destructor 'virtual Orientation::~Orientation()':
    ..\SolStats\orientation.cpp:14: warning: possible problem detected in invocation of delete operator:
    ..\SolStats\orientation.cpp:14: warning: invalid use of incomplete type 'struct QtMobility::QOrientationSensor'
    ..\SolStats/orientation.h:7: warning: forward declaration of 'struct QtMobility::QOrientationSensor'
    ..\SolStats\orientation.cpp:14: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
    ..\SolStats\orientation.cpp: In member function 'void Orientation::onReadingChanged()':
    ..\SolStats\orientation.cpp:19: error: 'QOrientationReading' was not declared in this scope
    ..\SolStats\orientation.cpp:19: error: 'reading' was not declared in this scope
    ..\SolStats\orientation.cpp:19: error: invalid use of incomplete type 'struct QtMobility::QOrientationSensor'
    ..\SolStats/orientation.h:7: error: forward declaration of 'struct QtMobility::QOrientationSensor'
    ..\SolStats\orientation.cpp:22: error: 'QOrientationReading' is not a class or namespace
    ..\SolStats\orientation.cpp:26: error: 'QOrientationReading' is not a class or namespace
    ..\SolStats\orientation.cpp:30: error: 'QOrientationReading' is not a class or namespace
    ..\SolStats\orientation.cpp:34: error: 'QOrientationReading' is not a class or namespace
    mingw32-make[1]: Leaving directory `C:/Projects/Mobile/SolStats-build-desktop'
    mingw32-make[1]: *** [debug/orientation.o] Error 1
    @



  • Are you including qmobilityglobal.h ?

    #include <qmobilityglobal.h>

    should solve your problem :D



  • Yes. I have included the Mobility global header in the orientation.cpp module. That avoids the QOrientationReading errors above. I just had a typo. (sorry)

    For some reason, no matter what I do QML is not recognising the new module.

    using Chris's method:
    main.cpp
    context->setContextProperty("Orientation", new Orientation(&app;));
    I get this error:
    ReferenceError: Can't find variable: Orientation

    If I do it a different way:
    orientation.h
    Q_DECLARATIVE_EXPORT class Orientation : public QObject
    {}

    main.cpp:
    qmlRegisterType<Orientation>("Orientation", 1, 0, "Orientation");

    main.qml:
    import Orientation 1.0;

    I only get this error:
    module "Orientation" is not installed

    Frustrating!
    I am missing something but I cannot for the life of me figure what it is.


    Well using both Linux and WinXP installations helps.

    When I booted into windows and ran the same code, I got this error:
    ReferenceError: Can't find variable: Orientation
    QSensorPluginLoader: Failed to load plugin
    Reason: o == 0
    Plugin: "C:/QtSDK/Simulator/Qt/mingw/plugins/sensors/qtsensors_genericd0.dll"
    Error: "The plugin 'C:/QtSDK/Simulator/Qt/mingw/plugins/sensors/qtsensors_genericd0.dll' uses incompatible Qt library. Expected build key "Windows mingw release full-config", got "Windows mingw debug full-config""
    QSensorPluginLoader: Failed to load plugin
    Reason: o == 0
    Plugin: "C:/QtSDK/Simulator/Qt/mingw/plugins/sensors qtsensors_simulatord1.dll"
    Error: "The plugin 'C:/QtSDK/Simulator/Qt/mingw/plugins/sensors/qtsensors_simulatord1.dll' uses incompatible Qt library. Expected build key "Windows mingw release full-config", got "Windows mingw debug full-config""
    loaded the Generic plugin

    I am running in release mode so this does not make sense. Maybe the makespecs do not point to the right plugin?



  • [quote author="ad5xj" date="1310745728"]
    When I booted into windows and ran the same code, I got this error:
    ReferenceError: Can't find variable: Orientation
    QSensorPluginLoader: Failed to load plugin
    Reason: o == 0
    Plugin: "C:/QtSDK/Simulator/Qt/mingw/plugins/sensors/qtsensors_genericd0.dll"
    Error: "The plugin 'C:/QtSDK/Simulator/Qt/mingw/plugins/sensors/qtsensors_genericd0.dll' uses incompatible Qt library. Expected build key "Windows mingw release full-config", got "Windows mingw debug full-config""
    QSensorPluginLoader: Failed to load plugin
    Reason: o == 0
    Plugin: "C:/QtSDK/Simulator/Qt/mingw/plugins/sensors qtsensors_simulatord1.dll"
    Error: "The plugin 'C:/QtSDK/Simulator/Qt/mingw/plugins/sensors/qtsensors_simulatord1.dll' uses incompatible Qt library. Expected build key "Windows mingw release full-config", got "Windows mingw debug full-config""
    loaded the Generic plugin

    I am running in release mode so this does not make sense. Maybe the makespecs do not point to the right plugin?
    [/quote]

    I just noticed this same problem, latest Qt SDK on Win7. Even more bizarrely, running in debug mode I get a similar error message, but then it tries to load the release version of the sensors plugin.



  • dur, my app still finds a buncha sensors, so it is working. Maybe it just tries to load all the plugins and complains about the incompatible one.


Log in to reply