Press Event
-
hi all,
I jus want to know if there is a long press event available in Qt :)
The module im working on currently requires long press. I have seen long press in C7 for uninstallingThe click event and the press event gives the same result right?
alfah
-
I found such a funtion,
can this be manipulated in some way??
@autoRepeat : bool
@
This property holds whether autoRepeat is enabled.
If autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted at regular intervals when the button is down. autoRepeat is off by default. The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval.
Note: If a button is pressed down by a shortcut key, then auto-repeat is enabled and timed by the system and not by this class. The pressed(), released(), and clicked() signals will be emitted like in the normal case.
Access functions:@
bool autoRepeat () const
void setAutoRepeat ( bool )
@alfah
-
Which kind of events are you talking about? Key presses? If so, your system can or can not generate a sequence of key press / key release events, but you can just check with QKeyEvent::isAutoRepeat if the event was generated due to a "true" keypress or is an autorepeat event.
-
peppe,
Sorry about not being clear. Yes, Im talking about key presses. I want to know to if there is a way to implement long key press. Ie if i click the button once it does an activity, if i press it twice it does another activity. Now I want to press and hold for some time to start yet another activity.
-
Yes, there is: just keep track of how many times AND how long a key has been pressed span and act accordingly. You just need to override key event handlers, and, as I said, ignore eventual autorepeat events.
-
i have implemented the first two. But it was not according to the key press event. How can i find out how long the key has been pressed? about overriding, could you jus gimme links of examples or jus elaborate on it?
Thank you,
-
[quote author="alfah" date="1313576475"]i have implemented the first two. But it was not according to the key press event. How can i find out how long the key has been pressed?[/quote]
QElapsedTimer?
[quote] about overriding, could you jus gimme links of examples or jus elaborate on it?
[/quote]See the QWidget::keyPressEvent / keyReleaseEvent methods, and the related discussion on event handling in Qt.