Pages
API Documentation
On this page

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

Public Functions

Signals

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:

Notifier signal:

[read-only] chargePercent : int

Access functions:

Notifier signal:

[read-only] chargeState : ChargeState

Access functions:

Notifier signal:

[read-only] cycleCount : int

Access functions:

Notifier signal:

[read-only] energy : double

Access functions:

Notifier signal:

[read-only] energyFull : double

Access functions:

Notifier signal:

[read-only] energyFullDesign : double

Access functions:

Notifier signal:

[read-only] energyRate : double

Access functions:

Notifier signal:

[read-only] powerSupply : bool

Access functions:

Notifier signal:

[read-only] present : bool

Access functions:

Notifier signal:

[read-only] rechargeable : const bool

Access functions:

[read-only] remainingTime : qlonglong

Access functions:

Notifier signal:

[read-only] serial : const QString

Access functions:

[read-only] technology : const Technology

Access functions:

[read-only] temperature : double

Access functions:

Notifier signal:

[read-only] timeToEmpty : qlonglong

Access functions:

Notifier signal:

[read-only] timeToFull : qlonglong

Access functions:

Notifier signal:

[read-only] type : const BatteryType

Access functions:

  • Solid::Battery::BatteryType type() const

[read-only] voltage : double

Access functions:

Notifier signal:

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.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.