[Qt-interest] Question regarding QTimer

Vesa Shmuel Peltonen vesashmuel at gmail.com
Thu Mar 17 08:07:38 CET 2011


Thanks guys for your help so far!

I'm checking the relevant object in the filter, and the filter is installed
on a custom Qwidget.

Here are the relevant traces. As you can see, the timer slot is called only
after the mouse is released. The timeout probably has happened before that,
because it is called immediately after mouse release event (when non zero
timeout is used).

[Qt Message] eventFilter: IN
[Qt Message] eventFilter: mouse press
[Qt Message] starting longpress timer with 0 timeout
[Qt Message] eventFilter: OUT

[Qt Message] eventFilter: IN
[Qt Message] eventFilter: mouse move
[Qt Message] eventFilter: OUT

[Qt Message] eventFilter: IN
[Qt Message] eventFilter: mouse move
[Qt Message] eventFilter: OUT

[Qt Message] eventFilter: IN
[Qt Message] eventFilter: mouse move
[Qt Message] eventFilter: OUT

[Qt Message] eventFilter: IN
[Qt Message] eventFilter: mouse release
[Qt Message] eventFilter: OUT

[Qt Message] longPressTimeOutSlot IN


On Wed, Mar 16, 2011 at 6:43 PM, Anton Chernov <mechernov at gmail.com> wrote:

> Where is you filter installed? Make sure this widget gets the events.
>
> By the way I would check if this is the right object in the params
> (*object) ... :) Installing this filter on qApp will cause you hell :)
>
> 2011/3/16 Vesa Shmuel Peltonen <vesashmuel at gmail.com>
>
>>  Yes, I know :)
>> The timer is started only once, when mouse is pressed. I expected, that
>> the timer will timeout after 150 ms even when the mouse is still down, but
>> it is not.
>> So, the sequence is this:
>> 1. Mouse press down
>> -> timer started (I tried even 0 with timeout)
>> 2. Mouse hold down for long time
>> 3. Mouse released
>> => timeout slot is called only here (even with 0 timeout).
>>
>> As I said, tried this only on S^3, maybe platform specific behavior?
>>
>> Thanks again,
>> Vesa
>>
>>
>> On Wed, Mar 16, 2011 at 5:16 PM, Atlant Schmidt <
>> aschmidt at dekaresearch.com> wrote:
>>
>>>  Vesa:
>>>
>>>
>>>
>>>   You know that QTimers are “retriggerable”, right? That is,
>>>   if you do an m_timer->start(150) multiple times, each
>>>   within 150 ms of the previous one, the timer doesn’t time-out
>>>   until 150 ms after the **LAST** call to start().
>>>
>>>   Perhaps you’re getting more MouseButtonPress events
>>>   than you think and they’re re-triggering your timer? Maybe
>>>   you can place some debugging print or some such in the
>>>   path that start()s the timer?
>>>
>>>
>>>
>>>                                       Atlant
>>>
>>>
>>>  ------------------------------
>>>
>>> *From:* qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com[mailto:
>>> qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] *On Behalf
>>> Of *Vesa Shmuel Peltonen
>>> *Sent:* Wednesday, March 16, 2011 10:39
>>> *To:* qt-interest at qt.nokia.com
>>> *Subject:* [Qt-interest] Question regarding QTimer
>>>
>>>
>>>
>>> Hello all,
>>>
>>>
>>>
>>> I've simple question. I'm trying to start a timer when mouse press event
>>> is received on eventfilter:
>>>
>>>
>>>
>>> xxx::eventFilter(QObject *object, QEvent *event)
>>>
>>> {
>>>
>>>
>>>
>>>     if ( event->type() == QEvent::MouseButtonPress )
>>>
>>>     {
>>>
>>>
>>>
>>>            m_timer->start(150); // msec
>>>
>>> ...
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> It seems that the timer timeouts always only after the mouse is released, even if the mouse press is very long (many seconds).
>>>
>>> Is this known behavior and is there way to overcome the problem? Is the system process blocking the application thread during the mouse press, so even if the timeout should have happen much earlier, the slot is called only after the mouse is released?
>>>
>>> Btw, my environment is Qt 4.7.2 on *S^3 device*. I've not tested the behavior on other platforms.
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Vesa
>>>
>>>
>>>
>>> Click here<https://www.mailcontrol.com/sr/xVgY2I1OSnbTndxI!oX7UiNQo6b55PW6E6Mk6PJ6lylK0Gxzl8M9JqgO7Csb+Br3JfPdjQoD3dvZM0Vr2cPI!w==>to report this email as spam.
>>>
>>> ------------------------------
>>> This e-mail and the information, including any attachments, it contains
>>> are intended to be a confidential communication only to the person or entity
>>> to whom it is addressed and may contain information that is privileged. If
>>> the reader of this message is not the intended recipient, you are hereby
>>> notified that any dissemination, distribution or copying of this
>>> communication is strictly prohibited. If you have received this
>>> communication in error, please immediately notify the sender and destroy the
>>> original message.
>>>
>>> Thank you.
>>>
>>> Please consider the environment before printing this email.
>>>
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110317/cb615756/attachment.html 


More information about the Qt-interest-old mailing list