Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

QPowerSource Class Reference
[QtBaseModule]

The QPowerSource class provides access to information about power sources on the device. More...

    #include <QPowerSource>

Inherits QHardwareInterface.

Inherited by QPowerSourceProvider.

Public Types

Public Functions

Signals

Additional Inherited Members


Detailed Description

The QPowerSource class provides access to information about power sources on the device.

Power sources are components, either external or internal, such as batteries or wall sockets that provide power to a Qt Extended device. The QPowerSource API allows applications to query the status of such components.

To access a list of QPowerSource instances, applications can use the QHardwareManager class. For example, to print out the charge percentage of each power source:

    QHardwareManager powerSources("QPowerSource");
    QStringList sources = powerSources.providers();

    foreach(QString source, sources) {
        QPowerSource powerSource(source);
        qWarning() << source << ":" << powerSource.charge() << "%";
        }

If an application or system component wants to provide information about a new power source, it should use the QPowerSourceProvider API.

See also QPowerSourceProvider and QPowerStatus.


Member Type Documentation

enum QPowerSource::Availability

Represents whether the power source is available.

ConstantValueDescription
QPowerSource::Available0The power source is available.
QPowerSource::NotAvailable1The power source is not available.
QPowerSource::Failed2The power source has failed.

enum QPowerSource::Type

Describes the type of the power source.

ConstantValueDescription
QPowerSource::Wall0This is a wall power source. Wall power sources are generally considered to provide infinite power, but are "unreliable" in that they may be disconnected at any time.
QPowerSource::Battery1This is a battery power source. Battery power sources provide a finite amount of power, but are considered "reliable".
QPowerSource::Virtual2This is a virtual power source. Virtual power sources do not correspond directly to a physical entity, but might, for example, be a virtual battery that consists of a weighted combination of other physical batteries.


Member Function Documentation

QPowerSource::QPowerSource ( const QString & id = QString(), QObject * parent = 0 )

Construct a new power source object for id with the specified parent.

If id is empty, this class will use the default provider that supports the power source interface.

QPowerSource::~QPowerSource ()   [virtual]

Destroys the QPowerSource instance.

Availability QPowerSource::availability () const

Returns the power source availability.

void QPowerSource::availabilityChanged ( QPowerSource::Availability availability )   [signal]

This signal is emitted whenever the availability of the power source changes. The new value is passed along via availability.

See also QPowerSource::availability() and QPowerSourceProvider::setAvailability().

int QPowerSource::capacity () const

Returns the capacity, in milliamp-hours of the power source of -1 if the capacity is unavailable or invalid.

void QPowerSource::capacityChanged ( int capacity )   [signal]

This signal is emitted whenever the power source capacity changes.

See also QPowerSource::capacity() and QPowerSourceProvider::setCapacity().

int QPowerSource::charge () const

Returns the current charge of the source in percentage, or -1 if the charge is unavailable or invalid.

void QPowerSource::chargeChanged ( int charge )   [signal]

This signal is emitted whenever the power source charge changes.

See also QPowerSource::charge() and QPowerSourceProvider::setCharge().

bool QPowerSource::charging () const

Returns true if the power source is charging, false if not.

void QPowerSource::chargingChanged ( bool isCharging )   [signal]

This signal is emitted whenever the power source changes the charging state. The new state is represented by isCharging.

See also QPowerSource::charging() and QPowerSourceProvider::setCharging().

int QPowerSource::timeRemaining () const

Returns the time remaining, in minutes, of the power source, or -1 if the time remaining is unavailable or invalid.

void QPowerSource::timeRemainingChanged ( int minutes )   [signal]

This signal is emitted whenever the time remaining, in minutes, changes .

See also QPowerSource::timeRemaining() and QPowerSourceProvider::setTimeRemaining().

Type QPowerSource::type () const

Returns the power source type.


Copyright © 2009 Trolltech Trademarks
Qt Extended 4.4.3