Solid::Battery Class
This device interface is available on batteries. More...
- Header:
#include <Solid/Battery> - CMake:
find_package(KF6 REQUIRED COMPONENTS Solid)
target_link_libraries(mytarget PRIVATE KF6::Solid) - Inherits: Solid::DeviceInterface
List of all members, including inherited members
Public Types
Properties
- [read-only] capacity : int
- [read-only] chargePercent : int
- [read-only] chargeState : ChargeState
- [read-only] cycleCount : int
- [read-only] energy : double
- [read-only] energyFull : double
- [read-only] energyFullDesign : double
- [read-only] energyRate : double
- [read-only] powerSupply : bool
- [read-only] present : bool
- [read-only] rechargeable : const bool
- [read-only] remainingTime : qlonglong
- [read-only] serial : const QString
- [read-only] technology : const Technology
- [read-only] temperature : double
- [read-only] timeToEmpty : qlonglong
- [read-only] timeToFull : qlonglong
- [read-only] type : const BatteryType
- [read-only] voltage : double
Public Functions
- int capacity() const
- int chargePercent() const
- Solid::Battery::ChargeState chargeState() const
- int cycleCount() const (since 6.9)
- double energy() const
- double energyFull() const
- double energyFullDesign() const
- double energyRate() const
- bool isPowerSupply() const
- bool isPresent() const
- bool isRechargeable() const
- qlonglong remainingTime() const
- QString serial() const
- Solid::Battery::Technology technology() const
- double temperature() const
- qlonglong timeToEmpty() const
- qlonglong timeToFull() const
- Solid::Battery::BatteryType type() const
- double voltage() const
Signals
- void capacityChanged(int value, const QString &udi)
- void chargePercentChanged(int value, const QString &udi)
- void chargeStateChanged(int newState, const QString &udi = QString())
- void cycleCountChanged(int value, const QString &udi) (since 6.9)
- void energyChanged(double energy, const QString &udi)
- void energyFullChanged(double energy, const QString &udi)
- void energyFullDesignChanged(double energy, const QString &udi)
- void energyRateChanged(double energyRate, const QString &udi)
- void powerSupplyStateChanged(bool newState, const QString &udi)
- void presentStateChanged(bool newState, const QString &udi)
- void remainingTimeChanged(qlonglong time, const QString &udi)
- void temperatureChanged(double temperature, const QString &udi)
- void timeToEmptyChanged(qlonglong time, const QString &udi)
- void timeToFullChanged(qlonglong time, const QString &udi)
- void voltageChanged(double voltage, const QString &udi)
Static Public Members
Detailed Description
Member Type Documentation
enum Battery::BatteryType
This enum type defines the type of the device holding the battery
| Constant | Value | Description |
|---|---|---|
Solid::Battery::PdaBattery |
1 |
A battery in a Personal Digital Assistant |
Solid::Battery::UpsBattery |
2 |
A battery in an Uninterruptible Power Supply |
Solid::Battery::PrimaryBattery |
3 |
A primary battery for the system (for example laptop battery) |
Solid::Battery::MouseBattery |
4 |
A battery in a mouse |
Solid::Battery::KeyboardBattery |
5 |
A battery in a keyboard |
Solid::Battery::KeyboardMouseBattery |
6 |
A battery in a combined keyboard and mouse |
Solid::Battery::CameraBattery |
7 |
A battery in a camera |
Solid::Battery::PhoneBattery |
8 |
A battery in a phone |
Solid::Battery::MonitorBattery |
9 |
A battery in a monitor |
Solid::Battery::GamingInputBattery |
10 |
A battery in a gaming input device (for example a wireless game pad) |
Solid::Battery::BluetoothBattery (since Qt 5.54) |
11 |
A generic Bluetooth device battery (if its type isn't known, a Bluetooth mouse would normally show up as a MouseBattery) |
Solid::Battery::TabletBattery (since Qt 5.88) |
12 |
A battery in a graphics tablet or pen |
Solid::Battery::HeadphoneBattery (since Qt 6.0) |
13 |
A battery in a headphone |
Solid::Battery::HeadsetBattery (since Qt 6.0) |
14 |
A battery in a headset |
Solid::Battery::TouchpadBattery (since Qt 6.0) |
15 |
A battery in a touchpad. This is how the Dualsense Wireless Controller is categorized |
Solid::Battery::WearableBattery (since Qt 6.21) |
16 |
A battery for a wearable device, watch... |
Solid::Battery::UnknownBattery |
0 |
A battery in an unknown device |
enum Battery::ChargeState
This enum type defines charge state of a battery
| Constant | Value | Description |
|---|---|---|
Solid::Battery::NoCharge |
0 |
Battery charge is stable, not charging or discharging or the state is Unknown |
Solid::Battery::Charging |
1 |
Battery is charging |
Solid::Battery::Discharging |
2 |
Battery is discharging |
Solid::Battery::FullyCharged |
3 |
The battery is fully charged; a battery not necessarily charges up to 100% |
enum Battery::Technology
Technology used in the battery
| Constant | Value | Description |
|---|---|---|
Solid::Battery::UnknownTechnology |
0 |
Unknown |
Solid::Battery::LithiumIon |
1 |
Lithium ion |
Solid::Battery::LithiumPolymer |
2 |
Lithium polymer |
Solid::Battery::LithiumIronPhosphate |
3 |
Lithium iron phosphate |
Solid::Battery::LeadAcid |
4 |
Lead acid |
Solid::Battery::NickelCadmium |
5 |
Nickel cadmium |
Solid::Battery::NickelMetalHydride |
6 |
Nickel metal hydride |
Property Documentation
[read-only] capacity : int
Access functions:
intcapacity() const
Notifier signal:
voidcapacityChanged(intvalue, constQString&udi)
[read-only] chargePercent : int
Access functions:
intchargePercent() const
Notifier signal:
voidchargePercentChanged(intvalue, constQString&udi)
[read-only] chargeState : ChargeState
Access functions:
Solid::Battery::ChargeStatechargeState() const
Notifier signal:
voidchargeStateChanged(intnewState, constQString&udi = QString())
[read-only] cycleCount : int
Access functions:
intcycleCount() const
Notifier signal:
voidcycleCountChanged(intvalue, constQString&udi)
[read-only] energy : double
Access functions:
doubleenergy() const
Notifier signal:
voidenergyChanged(doubleenergy, constQString&udi)
[read-only] energyFull : double
Access functions:
doubleenergyFull() const
Notifier signal:
voidenergyFullChanged(doubleenergy, constQString&udi)
[read-only] energyFullDesign : double
Access functions:
doubleenergyFullDesign() const
Notifier signal:
voidenergyFullDesignChanged(doubleenergy, constQString&udi)
[read-only] energyRate : double
Access functions:
doubleenergyRate() const
Notifier signal:
voidenergyRateChanged(doubleenergyRate, constQString&udi)
[read-only] powerSupply : bool
Access functions:
boolisPowerSupply() const
Notifier signal:
voidpowerSupplyStateChanged(boolnewState, constQString&udi)
[read-only] present : bool
Access functions:
boolisPresent() const
Notifier signal:
voidpresentStateChanged(boolnewState, constQString&udi)
[read-only] rechargeable : const bool
Access functions:
boolisRechargeable() const
[read-only] remainingTime : qlonglong
Access functions:
qlonglongremainingTime() const
Notifier signal:
voidremainingTimeChanged(qlonglongtime, constQString&udi)
[read-only] serial : const QString
Access functions:
QStringserial() const
[read-only] technology : const Technology
Access functions:
Solid::Battery::Technologytechnology() const
[read-only] temperature : double
Access functions:
doubletemperature() const
Notifier signal:
voidtemperatureChanged(doubletemperature, constQString&udi)
[read-only] timeToEmpty : qlonglong
Access functions:
qlonglongtimeToEmpty() const
Notifier signal:
voidtimeToEmptyChanged(qlonglongtime, constQString&udi)
[read-only] timeToFull : qlonglong
Access functions:
qlonglongtimeToFull() const
Notifier signal:
voidtimeToFullChanged(qlonglongtime, constQString&udi)
[read-only] type : const BatteryType
Access functions:
Solid::Battery::BatteryTypetype() const
[read-only] voltage : double
Access functions:
doublevoltage() const
Notifier signal:
voidvoltageChanged(doublevoltage, constQString&udi)
Member Function Documentation
int Battery::capacity() const
Returns the battery capacity normalised to percent, meaning how much energy can it hold compared to what it is designed to.
The capacity of the battery will reduce with age. A capacity value less than 75% is usually a sign that you should renew your battery.
Note: Getter function for property capacity.
[signal] void Battery::capacityChanged(int value, const QString &udi)
This signal is emitted when the capacity of this battery has changed.
Returns the new capacity value of the battery with the given udi.
Note: Notifier signal for property capacity.
int Battery::chargePercent() const
Returns the current charge level of the battery normalised to percent, or -1 if the charge level is unknown.
Note: Getter function for property chargePercent.
[signal] void Battery::chargePercentChanged(int value, const QString &udi)
This signal is emitted when the charge percent value of this battery has changed.
Returns the new charge percent value of the battery with the given udi.
Note: Notifier signal for property chargePercent.
Solid::Battery::ChargeState Battery::chargeState() const
Retrieves the current charge state of the battery.
It can be in a stable state (no charge), charging or discharging.
Note: Getter function for property chargeState.
See also Solid::Battery::ChargeState
[signal] void Battery::chargeStateChanged(int newState, const QString &udi = QString())
This signal is emitted when the charge state of this battery has changed.
Returns the new charge state newState of the battery with the given udi.
Note: Notifier signal for property chargeState.
[since 6.9] int Battery::cycleCount() const
Returns the number of charge cycles this battery has experienced so far, or -1 if this information is unavailable.
Note: Getter function for property cycleCount.
This function was introduced in Qt 6.9.
[signal, since 6.9] void Battery::cycleCountChanged(int value, const QString &udi)
This signal is emitted when the number of charge cycles of the battery has changed.
Returns the new value for the charge cycles of the battery with the given udi.
Note: Notifier signal for property cycleCount.
This function was introduced in Qt 6.9.
[static] Solid::DeviceInterface::Type Battery::deviceInterfaceType()
Returns the Solid::DeviceInterface::Type of the Battery device interface.
See also Solid::DeviceInterface::Type
double Battery::energy() const
Returns the amount of energy (measured in Wh) currently available in the power source.
Note: Getter function for property energy.
[signal] void Battery::energyChanged(double energy, const QString &udi)
This signal is emitted when the energy value of this battery has changed.
Returns the new energy value for the battery with the given udi.
Note: Notifier signal for property energy.
double Battery::energyFull() const
Returns the amount of energy (measured in Wh) the battery has when it is full.
Note: Getter function for property energyFull.
[signal] void Battery::energyFullChanged(double energy, const QString &udi)
This signal is emitted when the energy full value of this battery has changed.
Returns the new full energy value of the battery with the given udi.
Note: Notifier signal for property energyFull.
double Battery::energyFullDesign() const
Returns the amount of energy (measured in Wh) the battery should have by design when it is full.
Note: Getter function for property energyFullDesign.
[signal] void Battery::energyFullDesignChanged(double energy, const QString &udi)
This signal is emitted when the energy full design value of this battery has changed.
Returns the new energy full design value of the battery with the given udi.
Note: Notifier signal for property energyFullDesign.
double Battery::energyRate() const
Amount of energy being drained from the source, measured in W.
If positive, the source is being discharged, if negative it's being charged.
Note: Getter function for property energyRate.
[signal] void Battery::energyRateChanged(double energyRate, const QString &udi)
This signal is emitted when the energy rate value of this battery has changed.
If positive, the source is being discharged, if negative it's being charged.
Returns the new energy rate value of the battery with the given udi.
Note: Notifier signal for property energyRate.
bool Battery::isPowerSupply() const
Indicates if the battery is powering the machine.
Note: Getter function for property powerSupply.
bool Battery::isPresent() const
Returns whether this battery is currently present in its bay.
Note: Getter function for property present.
bool Battery::isRechargeable() const
Indicates if the battery is rechargeable.
Note: Getter function for property rechargeable.
[signal] void Battery::powerSupplyStateChanged(bool newState, const QString &udi)
This signal is emitted when the power supply state of the battery changes.
Returns the newState for the power supply of the battery with the given udi.
Note: Notifier signal for property powerSupply.
[signal] void Battery::presentStateChanged(bool newState, const QString &udi)
This signal is emitted if the battery gets plugged in/out of the battery bay.
Returns the newState of the battery with the given udi.
Note: Notifier signal for property present.
qlonglong Battery::remainingTime() const
Retrieves the current estimated remaining time (in seconds) of the system batteries
Note: Getter function for property remainingTime.
[signal] void Battery::remainingTimeChanged(qlonglong time, const QString &udi)
This signal is emitted when the estimated battery remaining time changes.
Returns the new battery remaining time for the battery with the given udi.
Note: Notifier signal for property remainingTime.
QString Battery::serial() const
The serial number of the battery
Note: Getter function for property serial.
Solid::Battery::Technology Battery::technology() const
Returns the technology used to manufacture the battery.
Note: Getter function for property technology.
See also Solid::Battery::Technology
double Battery::temperature() const
The temperature of the battery in degrees Celsius.
Note: Getter function for property temperature.
[signal] void Battery::temperatureChanged(double temperature, const QString &udi)
This signal is emitted when the battery temperature has changed.
Returns the new temperature of the battery in degrees Celsius.
Note: Notifier signal for property temperature.
qlonglong Battery::timeToEmpty() const
Time (in seconds) until the battery is empty.
Note: Getter function for property timeToEmpty.
[signal] void Battery::timeToEmptyChanged(qlonglong time, const QString &udi)
This signal is emitted when the time until the battery is empty has changed.
Returns the new remaining time until empty of the battery with the given udi.
Note: Notifier signal for property timeToEmpty.
qlonglong Battery::timeToFull() const
Time (in seconds) until the battery is full.
Note: Getter function for property timeToFull.
[signal] void Battery::timeToFullChanged(qlonglong time, const QString &udi)
This signal is emitted when the time until the battery is full has changed.
Returns the new remaining time until full of the battery with the given udi.
Note: Notifier signal for property timeToFull.
Solid::Battery::BatteryType Battery::type() const
Returns the type of device holding this battery.
Note: Getter function for property type.
See also Solid::Battery::BatteryType
double Battery::voltage() const
Voltage in the Cell or being recorded by the meter.
Note: Getter function for property voltage.
[signal] void Battery::voltageChanged(double voltage, const QString &udi)
This signal is emitted when the voltage in the cell has changed.
Returns the new voltage of the cell for the battery with the given udi.
Note: Notifier signal for property voltage.