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

[Solved] Cannot include QSystemDeviceInfo



  • I gave a comment on DevNet Documentation review that each API documentation should also carry any .pro file changes that are required to include that header file and use it inside the code. That should remove lot of confusions.



  • [quote author="spode" date="1310117532"]and what about QtQuick project?[/quote]

    For Qt Quick, above mentioned .pro file changes are good enough.

    And you need to have @import QtMobility.systeminfo 1.1@ in your .qml file

    And DeviceInfo is the qml element name.



  • They are listed. See this "quickstart guide":http://doc.qt.nokia.com/qtmobility-1.2/quickstart.html for mobility.

    @spode What do you mean? You can still use C++ in a QtQuick project. If you wan tto display it you just need to bind to the respective properties and possibly expose the info you need as properties if they are not already available.



  • @Vijay Ah that's even better then. I have not looked into using mobility directly in QML yet.



  • @
    import Qt 4.7
    import QtMobility.systeminfo 1.1

    Rectangle{
    ....

    DeviceInfo {
        id: deviceinfo;
        //        onBatteryStatusChanged : doBatteryStatusChange(status);
        onPowerStateChanged : getPowerState(/*powerState*/);
        onBatteryLevelChanged: doBatteryLevelChange(level)
        property int battlevel: batteryLevel;
    
        monitorBatteryLevelChanges: true
        monitorBatteryStatusChanges: true
        monitorPowerStateChanges: true
        monitorCurrentProfileChanges: true
        monitorBluetoothStateChanges: true
    }
    ...
    

    }
    @



  • 0k, but what about .cpp? why can not i include QSystemDeviceInfo.h?



  • Have you tried:

    @
    #include <QSystemDeviceInfo>
    @

    ie without the ".h" suffix. Can you post the exact command line passed to the compiler and error msg please? That way we can see if it has the correct -I arguments or not.



  • on .cpp:
    error: QSystemDeviceInfo: No such file or directory
    althought i am using windows 7 and Qt 4.7.3



  • And the command line passed to the compiler please? Which target are you trying to build for?





  • all right. perhaps it was because i wrote "mobility" instead of "MOBILITY" in CONFIG and did not write "symbian:TARGET.CAPABILITY = ReadDeviceData" in .pro file.
    thank everybody!



  • Yes the MOBILITY variable in the .pro file needs to be in uppercase. The missing symbian capabilities flag would have caused errors later on in the compilation (or maybe at runtime).

    Glad to see you hav eit working now. Good luck with the rest of your project.



  • thank you! :)



  • I am making a desktop app and not able to include QSystemDeviceInfo all the above steps i have tried but it dosnt work its giving error no such QSystemDeviceInfo file.i m using qt 4.7



  • Did you try to reinstall qt?



  • ya i have tried in 3 system but it didnt worked i am compiling it by desktop compiler not Symbian or etc...



  • What is the application output?



  • QSystemDeviceInfo: No such file or directory



  • As for me with QMessage. But if I go to the folder that contains qmessage.h, the file stays there. What about you?



  • i am not able to even compile the code because of QSystemDeviceInfo: No such file or directory
    as i have added below in pro file
    symbian:TARGET.CAPABILITY = ReadDeviceData
    CONFIG += mobility
    MOBILITY += systeminfo

    and trying to run in qt desktop mode of compiler



  • i will edit the title to continue this discussion.



  • that is it:
    @
    #include <QScrollArea>
    #include <QDialog>
    #include <QtSystemInfo/QSystemInfo>

    #include <qmessage.h>

    QTM_USE_NAMESPACE

    PaginaPercheWortfluss::PaginaPercheWortfluss(QTabWidget *parent) :
    QTabWidget(parent)
    {
    this->setAttribute(Qt::WA_LockLandscapeOrientation);

    QWidget * widget1 = new QWidget;//informazioni
    QVBoxLayout *layou = new QVBoxLayout(widget1);
    QLabel *titolo1 = new QLabel(QString("<h2>Wortfluss: informazioni</h2>"));
    QLabel *testoInfo;
    

    ...
    @

    QTM_USE_NAMESPACE!!! ;)


Log in to reply