Force QPushButton release

  • Hi all,
    I have a QPushButton and 2 connection to its signal pressed and released:

    connect(button, SIGNAL(pressed()), this, SLOT(button_pressed()));
    connect(button, SIGNAL(released()), this, SLOT(button_released()));

    then I have a timer that sometimes disable the button.

    If I press the button and it become disabled I need to call button_released().

    I need something like this:
    connect(button, SIGNAL(disabled()), this, SLOT(button_released()));

    but button hasn't "disabled" signal.

  • What about to handle it in your timer, like this?
    if(button->isDown()) {
    button_released(); // or maybe emit released if you are in button subclass?

  • Thanks,
    it's a good solution, but for me it should be better to emit "released" signal when disabled.

    If there is no way to emit released() I think I'll subclass QPushButton .

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.