[Interest] Globally Converting QTapAndHoldGesture to Mouse Double Click
Joshua Grauman
jnfo-c at grauman.com
Fri Feb 22 23:05:38 CET 2013
That is a good thought, but I don't think that is the problem. I have a
double click event handler on one of my widgets, and it's not even getting
called. I would think that sending a double click event would cause the
double click event handler to be called, so that's why I think that
somehow I'm not sending the double click event correctly or somehow it
isn't getting to the appropriate widget... Thanks.
Josh
> Hi Josh,
>
> I think most widgets are expecting Press, Release, DoubleClick, Release
> sequences.
>
> In my own code, I've had to set a flag on the double-click, then action it
> on the following release. This was where the double-click was to open
> another dialog. Without this, the release would trigger a click in the new
> form, which the client did not want to occur.
>
> Maybe QInputMethod might be more appropriate in your case?
>
> Hope that helps.
>
> Tony
>
>
>> Sent: Friday, 22 February 2013 4:36 PM
>>
>> Hello all,
>>
>> I'm trying to write a global proceedure to convert all QTapAndHoldGesture
>> events to mouse double click events. I thought this should be trivial, but
> it's
>> really stumping me.
>>
>> I setup an event filter globally for my QApplication and grab the gesture
> as
>> follow:
>> app.installEventFilter(&myobj);
>> mainWin->grabGesture(Qt::TapAndHoldGesture);
>>
>> And then I have an event filter as follows:
>>
>> bool myObject::eventFilter(QObject *obj, QEvent *e)
>> {
>> if(e->type() == QEvent::Gesture)
>> {
>> QGestureEvent *event = static_cast<QGestureEvent*>(e);
>> if(QGesture *gest = event->gesture(Qt::TapAndHoldGesture))
>> {
>> QTapAndHoldGesture *tah = static_cast<QTapAndHoldGesture *>(gest);
>> QMouseEvent dblClk(QEvent::MouseButtonDblClick, tah-
>>> position().toPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
>> QApplication::sendEvent(obj, &dblClk);
>> return true;
>> }
>> }
>> }
>>
>> I receive the gesture events fine, but for some reason when none of my
>> widgets receive the double click events. I've tried lots of different
>> options for instantiating my QMouseEvent. I've tried calling grabMouse on
>> the widget before sending the event, but still nothing receives double
>> click events. Does anyone have an idea of why none of my widgets receive
>> the double click events?
>>
>> Thanks!
>>
>> Josh
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
More information about the Interest
mailing list