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. PushButton setDisable Issues
Forum Updated to NodeBB v4.3 + New Features

PushButton setDisable Issues

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 5 Posters 587 Views 2 Watching
  • 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.
  • S Offline
    S Offline
    Simof
    wrote on last edited by
    #1

    Dear All,

    When a PushButton is disabled all its signals are disabled automatically?
    Is possible disable temporary the button and maintaining his signals when It will re-enabled?

    JonBJ raven-worxR Pl45m4P 3 Replies Last reply
    0
    • S Simof

      Dear All,

      When a PushButton is disabled all its signals are disabled automatically?
      Is possible disable temporary the button and maintaining his signals when It will re-enabled?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Simof
      A disabled widget does not generate (normal) signals. Yes when it is reenabled it reverts to sending signals, and any slots connected are preserved.

      1 Reply Last reply
      0
      • S Simof

        Dear All,

        When a PushButton is disabled all its signals are disabled automatically?
        Is possible disable temporary the button and maintaining his signals when It will re-enabled?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @Simof said in PushButton setDisable Issues:

        When a PushButton is disabled all its signals are disabled automatically?

        no, disabled means it wont react to/process certain events

        Is possible disable temporary the button and maintaining his signals when It will re-enabled?

        about what signals are you talking about? and whats the actual use case you are after?
        if its just the clicked signal you can install an eventfilter on the button.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        2
        • S Simof

          Dear All,

          When a PushButton is disabled all its signals are disabled automatically?
          Is possible disable temporary the button and maintaining his signals when It will re-enabled?

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @Simof

          Then you are using the disabled property wrong. If you disable a button, there should not be any user interaction going on (because there's probably a reason why you disabled this button).

          You want to store your signals in some sort of queue and send them as soon as the button get enabled again?! Is this what you are trying?
          Changing the enabled / disabled state, doesn't do anything to your slots connected to the button.

           In general an enabled widget handles keyboard and mouse events; a disabled widget does not. An exception is made with QAbstractButton.
          

          (https://doc.qt.io/qt-5/qwidget.html#enabled-prop)

           Note: As opposed to other widgets, buttons derived from QAbstractButton accept mouse and context menu events when disabled.
          

          (https://doc.qt.io/qt-5/qabstractbutton.html)


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          1
          • S Offline
            S Offline
            Simof
            wrote on last edited by
            #5

            Thanks for your answer.

            I made this question because when i disable and next re-enable the qpushbutton its signal "clicked()" don't call my slot.

            I'll try to understand why!

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Simof said in PushButton setDisable Issues:

              I'll try to understand why!

              At least not because you disable/enable the button. Please show a minimal, compilable example for your issue.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1
              • S Offline
                S Offline
                Simof
                wrote on last edited by
                #7

                I understand the mistake.
                I'm using a custom class hinerit from QPushButton and I rewrite the setDisabled() function.
                I thought I was enabling it correctly but it wasn't

                void ClickableLabel::setDisabled(bool en)
                {
                    if(en)
                    {
                        QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect();
                        effect->setOpacity(0.4);
                        this->setGraphicsEffect(effect);
                       ---> BEFORE <--- QPushButton::setDisabled(en);
                    }
                    else
                    {
                        if(enShadow) setUnpressedShadow();
                    }
                    ---> AFTER<---  QPushButton::setDisabled(en);
                }
                
                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