Pages
API Documentation
On this page

KLed Class

An LED widget. More...

  • Header: #include <KLed>
  • CMake: find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
    target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons)
  • Inherits: QWidget

List of all members, including inherited members

Public Types

Properties

Public Functions

Public Slots

Detailed Description

Displays a round or rectangular light emitting diode.

It is configurable to arbitrary colors, the two on/off states and three styles (or "looks");

It may display itself in a performant flat view, a round view with light spot or a round view sunken in the screen.

Member Type Documentation

enum KLed::Look

Displays a flat, round or sunken LED.

LED look.

Constant
KLed::Flat 0
KLed::Raised 1
KLed::Sunken 2

enum KLed::Shape

Shades of the lamp.

LED shape

Constant
KLed::Rectangular 0
KLed::Circular 1

enum KLed::State

Status of the light is on/off.

LED on/off.

Constant
KLed::Off 0
KLed::On 1

Property Documentation

color : QColor

Access functions:

darkFactor : int

Access functions:

look : Look

Access functions:

  • KLed::Look look() const
  • void setLook(KLed::Look look)

shape : Shape

Access functions:

state : State

Access functions:

Member Function Documentation

[explicit] KLed::KLed(QWidget *parent = nullptr)

Constructs a green, round LED widget which will initially be turned on.

parent The parent widget.

[explicit] KLed::KLed(const QColor &color, QWidget *parent = nullptr)

Constructs a round LED widget with the supplied color which will initially be turned on.

color Initial color of the LED.

parent The parent widget.

KLed::KLed(const QColor &color, KLed::State state, KLed::Look look, KLed::Shape shape, QWidget *parent = nullptr)

Constructor with the color, state and look.

Differs from above only in the parameters, which configure all settings.

color Initial color of the LED.

state Sets the State.

look Sets the Look.

shape Sets the Shape (rectangular or circular).

parent The parent widget.

QColor KLed::color() const

Returns the current color of the widget.

Note: Getter function for property color.

See also setColor()

int KLed::darkFactor() const

Returns the factor to darken the LED.

Note: Getter function for property darkFactor.

See also setDarkFactor()

KLed::Look KLed::look() const

Returns the current look of the widget.

Note: Getter function for property look.

See also setLook(), Look

[slot] void KLed::off()

Sets the state of the widget to Off.

See also on(), toggle(), setState()

[slot] void KLed::on()

Sets the state of the widget to On.

See also off(), toggle(), setState()

void KLed::setColor(const QColor &color)

Set the color of the widget.

The LED is shown with color when in the KLed::On state or with the darken color in KLed::Off state.

The widget calls the update() method, so it will be updated when entering the main event loop.

color New color of the LED.

Note: Setter function for property color.

See also color(), darkFactor()

void KLed::setDarkFactor(int darkFactor)

Sets the factor to darken the LED in KLed::Off state.

The darkFactor should be greater than 100, otherwise the LED becomes lighter in KLed::Off state.

Defaults to 300.

darkFactor Sets the factor to darken the LED.

Note: Setter function for property darkFactor.

See also darkFactor(), setColor

void KLed::setLook(KLed::Look look)

Sets the look of the widget.

The look may be Flat, Raised or Sunken.

The widget calls the update() method, so it will be updated when entering the main event loop.

look New look of the LED.

Note: Setter function for property look.

See also look(), Look

void KLed::setShape(KLed::Shape shape)

Set the shape of the LED.

shape The LED shape.

Set LED shape.

Note: Setter function for property shape.

See also shape()

void KLed::setState(KLed::State state)

Sets the state of the widget to On or Off.

state The LED state: on or off.

Note: Setter function for property state.

See also state(), on(), off(), toggle()

KLed::Shape KLed::shape() const

Returns the current shape of the widget.

Note: Getter function for property shape.

See also setShape(), Shape

KLed::State KLed::state() const

Returns the current state of the widget (on/off).

Note: Getter function for property state.

See also setState(), State

[slot] void KLed::toggle()

Toggles the state of the led from Off to On or vice versa.

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