Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved QPushButton::pressed()

    General and Desktop
    3
    5
    830
    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.
    • ivanicy
      ivanicy last edited by

      Hello!

      I am trying to do something when I push a button. I thought that when I press a button (QPushButton::pressed()), the function inside the button will execute in loop, but it only enters the slot once.

      What can I do? Thank you very much!

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @ivanicy last edited by

        @ivanicy said in QPushButton::pressed():

        the function inside the button will execute in loop

        what?? What are you trying to achieve exactly?
        Do you mean that the signal is triggered repeatedly as long as the button is held down?

        The signal is only emitted once when the mouse press event is received.

        --- 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

        ivanicy 1 Reply Last reply Reply Quote 3
        • ivanicy
          ivanicy @raven-worx last edited by

          @raven-worx

          Is exactly that. I want to keep the button hold and do the function inside it until I released the button.

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @ivanicy last edited by

            @ivanicy
            Hi
            If you make a loop inside a button, you will strangulate
            whole application.

            Its better to use the auto repeat feature
            http://doc.qt.io/qt-5/qabstractbutton.html#autoRepeat-prop

            and perform function as long as its repeating the signal

            Looping will make you sad :)

            ivanicy 1 Reply Last reply Reply Quote 4
            • ivanicy
              ivanicy @mrjj last edited by

              @mrjj Thank you very much!!!

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