Search code examples
c++qtsignals-slots

How can I do Qt QLed signal slot connection?


I want to connect led with signal slots. When the led status changed i want to do something. Here by signal slot code;

QLed*        ledAliveStatus;
connect(ledAliveStatus, SIGNAL(valueChanged(bool)), this, SLOT(CheckConfiguration(bool)));

When i debug the program, it gave me

Object::connect: No such signal QLed::valueChanged(bool)

The Qled class signal slots methods can be seen the below. I tried to LedStateChaned(bool) instead of value changed but it gave me the same error.

// User-defined attributes

signals:
void ledStateChanged(bool);
void ledRotationChanged(double);
void ledStateToggled();

public slots:
void setLedState(const bool &ledState);
void setLedStretch(const bool &ledStretch);
void setLedShape(const LedShape &ledShape);
void setLedType(const LedType &ledType);

Solution

  • There is no signal named valueChanged(). You should use

    connect(ledAliveStatus, SIGNAL(ledStateChanged(bool)), this, SLOT(CheckConfiguration(bool)));