Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Force QPushButton release

    General and Desktop
    2
    3
    4716
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      luca last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • Q
        Queria last edited by

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

        more or less maybe sooner but probably later

        1 Reply Last reply Reply Quote 0
        • L
          luca last edited by

          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 .

          1 Reply Last reply Reply Quote 0
          • First post
            Last post