qtbuttonmousepressedclick

QPushButton() should react as long as it is pressed


I am using QPushButton() in my programme. With these buttons I rotate my object. Works fine so far. The only Problem is that i have to click multiple times to rotate the object a little further. This is a bit annoying. Isnt there a possibility that the button will stay pressed as long as I press it and the object will rotate further. There is the function pressed(), but there is no difference to clicked().


Solution

  • QAbstractButton has an auto-repeat feature that you can turn on:

    button->setAutoRepeat(true);
    

    This will emit the pressed(), released(), and clicked() signals repeatedly. You can also specify how often the signals are emitted (setAutoRepeatInterval), and how long the button waits before it starts emitting them (setAutoRepeatDelay).