Low Battery



  • Hi All

    In my QT dialog application I need to show low battery information.
    As soon as battery low I need to display low battery Icon in my application
    How do I get this information in my program.

    thanks in advance
    :)



  • Clear enough?:
    In .h file:
    @Q_PROPERTY(int batteryLevel READ batteryLevel WRITE setBatteryLevel NOTIFY charging)@

    And somewhere in class constructor
    @si = new QSystemDeviceInfo(this);@
    @
    int myClass::getBattery()
    {
    this->setBatteryLevel(si->batteryLevel());
    return m_batteryLevel;
    }
    @
    [Edit: Code formatting; mlong]


  • Moderators

    Here is the documentation of the QSystemDeviceInfo class: http://doc.qt.nokia.com/qtmobility-1.0-tp/qsystemdeviceinfo.html

    I would just use that class directly in favor of using the code suggested earlier.



  • In my application I am getting

    • error: QSystemDeviceInfo: No such file or directory*

    I have included QSystemDeviceInfo in my header file

    @#include <QSystemDeviceInfo>@



  • I do @#include <QSystemDeviceInfo>@

    twice - in header and in .cpp file.
    Be sure to have correct .pro file:
    @CONFIG += mobility
    MOBILITY += systeminfo @

    Learn the basis!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.