Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Force QPushButton release

Force QPushButton release

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.0k Views
  • 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 Offline
    L Offline
    luca
    wrote on last edited by
    #1

    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
    0
    • Q Offline
      Q Offline
      Queria
      wrote on last edited by
      #2

      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
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved