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 last edited by VRonin
    #1

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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #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
      5
      • VRoninV VRonin
        widget->setEnabled(false);
        QTimer::singleShot(1000,widget,std::bind(&QWidget::setEnabled,widget,true));
        
        K Offline
        K Offline
        Kinesis
        wrote on last edited by
        #3

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

        J.HilkJ 1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #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
          0
          • K Kinesis

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

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on 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
            3
            • VRoninV VRonin

              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 last edited by
              #6

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

              1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @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 last edited by
                #7

                @J.Hilk
                It works ! THANKS :-)

                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