我使用Qt 4.8.X在Linux上使用X11和/或Qt-QWS以及从QAbstractButton派生的自定义按钮。 现在我必须区分按下按钮,释放按钮和按住按钮的用户。 为此,我想使用QAbstractButton :: autoRepeat,如本问题所述 。 正如QT文档所述
如果启用了autoRepeat,则会定期发出pressed(),released()和clicked()信号。
那么,当所有三个信号一起发射时,我现在如何区分实际按下,按住和释放按钮? 您的想法非常受欢迎。 谢谢和问候。
I am using Qt 4.8.X on Linux with X11 and/or Qt-QWS with custom buttons derived from QAbstractButton. Now I have to distinguish between a button press, release and the user holding down the button. To do so, I would like to use QAbstractButton::autoRepeat as described in this question. As the QT Documentation states
If autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted at regular intervals.
Well, how can I now distinguish between actually pressing down, holding down and releasing the button when all three Signals get emitted together? Your ideas are very welcome. Thanks and greeting.
最满意答案
也许使用autoRepeat不是最好的主意。 我不知道你想要做什么,但我的第一个猜测是关闭autoRepeat。 如果用户按下按钮,您将获得按下的信号。 在该回调中,您可以启动一个在您所需的“自动重复”间隔内触发的计时器。 如果用户再次释放按钮(信号释放),您只需停止或终止计时器。
Maybe using autoRepeat is not the best idea here. I do not know what you want to do exactly, but my first guess would be leaving autoRepeat off. If the user presses the button, you get your pressed signal. In that callback you can start a timer that fires in your desired "auto Repeat" interval. If the user releases the button again (signal released), your just stop or kill the timer.
更多推荐
发布评论