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. How to disable widget for 1second
QtWS25 Last Chance

How to disable widget for 1second

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatorqlistwidget
7 Posts 3 Posters 1.1k 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.
  • K Offline
    K Offline
    Kinesis
    wrote on 2 Aug 2018, 09:29 last edited by VRonin 8 Feb 2018, 09:44
    #1

    How can I disable the listWidget for 1second and enable it again?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 2 Aug 2018, 09:34 last edited by VRonin 8 Feb 2018, 09:44
      #2
      widget->setEnabled(false);
      QTimer::singleShot(1000,widget,std::bind(&QWidget::setEnabled,widget,true));
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      K 1 Reply Last reply 2 Aug 2018, 09:41
      5
      • V VRonin
        2 Aug 2018, 09:34
        widget->setEnabled(false);
        QTimer::singleShot(1000,widget,std::bind(&QWidget::setEnabled,widget,true));
        
        K Offline
        K Offline
        Kinesis
        wrote on 2 Aug 2018, 09:41 last edited by
        #3

        @VRonin
        That looks right. But I got an error "no matching function for call to 'bind'".

        J 1 Reply Last reply 2 Aug 2018, 09:44
        0
        • V Offline
          V Offline
          VRonin
          wrote on 2 Aug 2018, 09:43 last edited by VRonin 8 Feb 2018, 09:44
          #4

          Fixed my code above, I was missing an argument

          • did you #include <functional>?
          • are you using Qt >= 5.4?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          K 1 Reply Last reply 2 Aug 2018, 09:46
          0
          • K Kinesis
            2 Aug 2018, 09:41

            @VRonin
            That looks right. But I got an error "no matching function for call to 'bind'".

            J Offline
            J Offline
            J.Hilk
            Moderators
            wrote on 2 Aug 2018, 09:44 last edited by
            #5

            @Kinesis
            I'm to lazy to google my way to the correct include for std::bind, so my suggestion lambda your way through it

            widget->setEnabled(false);
            QTimer::singleShot(1000,widget,[widget]{widget->setEnabled(true);});
            

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            K 1 Reply Last reply 2 Aug 2018, 09:47
            3
            • V VRonin
              2 Aug 2018, 09:43

              Fixed my code above, I was missing an argument

              • did you #include <functional>?
              • are you using Qt >= 5.4?
              K Offline
              K Offline
              Kinesis
              wrote on 2 Aug 2018, 09:46 last edited by
              #6

              @VRonin
              I did #include <functional>
              I am using Qt>=5.11.0.

              1 Reply Last reply
              0
              • J J.Hilk
                2 Aug 2018, 09:44

                @Kinesis
                I'm to lazy to google my way to the correct include for std::bind, so my suggestion lambda your way through it

                widget->setEnabled(false);
                QTimer::singleShot(1000,widget,[widget]{widget->setEnabled(true);});
                
                K Offline
                K Offline
                Kinesis
                wrote on 2 Aug 2018, 09:47 last edited by
                #7

                @J.Hilk
                It works ! THANKS :-)

                1 Reply Last reply
                0

                6/7

                2 Aug 2018, 09:46

                • Login

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