PDA

View Full Version : Qt Multi-touch Dials example not working as expected



dpatel
19th November 2010, 13:32
Hi,

I am trying to test the Dials Multitouch example which comes along with Qt. I am not sure is the issue in my setup, touch screen or Qt. I am facing exactly same issue (well partially) described here (http://www.qtcentre.org/threads/29713-touchEvent-register-on-a-single-widget-on-a-multitouch-screen)

Here is my project setup.

Qt 4.6.2
Qt Creator 1.3.1
Win 7 32 bit OS
Hp Compaq L2105tm Multitouch Monitor (supports 2 touches)

I am able to compile and run the application with following issues.

Firstly I have to add in main.cpp of the example (to receive multitouch event even for the first time)



QCoreApplication::setAttribute(Qt::AA_DontCreateNa tiveWidgetSiblings);


In release mode I can rotate two knobs only for the first time for each knob.
Usecases
Rotate knb1 knb2 -> works fine first time
Rotate knb1 knb2 again -> only one knob will rotate.
Rotate knb3 knb4 -> works fine since these knobs are rotated for the first time.
Now any combination of knobs between 1-4 will not work as expected. Only one knob is rotated even if I try to rotate two knobs.

In debug mode all the above cases work fine, i.e I can rotate any combination of two knobs any number of times (70% of times). Sometimes debug build is also not working as expected.

After digging into the issue for two days I found

(1) that in case of failures the touch event is directly received by the knobs and in case of correct behavior the touch event is first received by containing widget of knobs(int this case its QWidget) and from there the event is propagated to respective knob.

(2) In case of correct behavior the code returns from


if (!isActive())
{
return;
}

which is at around line 230 in qt\src\gui\accessible\qaccessible_win.cpp. While in case of incorrect behavior the code goes further down in that function.

In case if its of any help, here goes the stack trace in case of correct behavior



0 QDial::mouseMoveEvent qdial.cpp 349 0x00a29e70
1 QWidget::event qwidget.cpp 7983 0x006dc938
2 QAbstractSlider::event qabstractslider.cpp 956 0x009fbe56
3 QDial::event qdial.cpp 508 0x00a2a2a0
4 QApplicationPrivate::notify_helper qapplication.cpp 4300 0x00692520
5 QApplication::notify qapplication.cpp 3865 0x00690723
6 QCoreApplication::notifyInternal qcoreapplication.cpp 704 0x6a1fd302
7 QCoreApplication::sendEvent qcoreapplication.h 215 0x00ce6f9e
8 QWidget::event qwidget.cpp 8431 0x006ddbcf
9 QAbstractSlider::event qabstractslider.cpp 956 0x009fbe56
10 QDial::event qdial.cpp 508 0x00a2a2a0
11 QApplicationPrivate::notify_helper qapplication.cpp 4300 0x00692520
12 QApplication::notify qapplication.cpp 4265 0x006923a0
13 QCoreApplication::notifyInternal qcoreapplication.cpp 704 0x6a1fd302
14 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 218 0x00ce6f4a
15 QApplicationPrivate::translateRawTouchEvent qapplication.cpp 5670 0x006941fc
16 QApplicationPrivate::translateTouchEvent qapplication_win.cpp 4067 0x006fa075
17 QtWndProc@16 qapplication_win.cpp 1680 0x006f2e8f
18 USER32!IsWindowVisible C:\Windows\system32\user32.dll 0 0x777f86ef
19 ?? 0 0x00060534
20 ?? 0 0x00000240


Stack trace in case of incorrect behavior


0 QWidgetPrivate::registerTouchWindow qwidget_win.cpp 2050 0x0096e706
1 QWidgetPrivate::create_sys qwidget_win.cpp 494 0x00968781
2 QWidget::create qwidget.cpp 1319 0x0092ba61
3 QWidgetPrivate::createWinId qwidget.cpp 2310 0x0092f84e
4 QWidget::setAttribute qwidget.cpp 10392 0x00940f38
5 QWidget::winId qwidget.cpp 2281 0x0092f63a
6 QAccessible::updateAccessibility qaccessible_win.cpp 286 0x00db2145
7 QAbstractSlider::setValue qabstractslider.cpp 539 0x00c5b49a
8 QAbstractSlider::triggerAction qabstractslider.cpp 631 0x00c5b6fd
9 QAbstractSlider::setSliderPosition qabstractslider.cpp 499 0x00c5b397
10 QDial::mouseMoveEvent qdial.cpp 356 0x00c89ef6
11 QWidget::event qwidget.cpp 7983 0x0093c938
12 QAbstractSlider::event qabstractslider.cpp 956 0x00c5be3a
13 QDial::event qdial.cpp 508 0x00c8a284
14 QApplicationPrivate::notify_helper qapplication.cpp 4300 0x008f2520
15 QApplication::notify qapplication.cpp 3865 0x008f0723
16 QCoreApplication::notifyInternal qcoreapplication.cpp 704 0x6a1fd302
17 QCoreApplication::sendEvent qcoreapplication.h 215 0x00f46f7e
18 QWidget::event qwidget.cpp 8430 0x0093dbb3
19 QAbstractSlider::event qabstractslider.cpp 956 0x00c5be3a
20 QDial::event qdial.cpp 508 0x00c8a284
21 QApplicationPrivate::notify_helper qapplication.cpp 4300 0x008f2520
22 QApplication::notify qapplication.cpp 4265 0x008f23a0
23 QCoreApplication::notifyInternal qcoreapplication.cpp 704 0x6a1fd302
24 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 218 0x00f46f2a
25 QApplicationPrivate::translateRawTouchEvent qapplication.cpp 5670 0x008f41fc
26 QApplicationPrivate::translateTouchEvent qapplication_win.cpp 4067 0x0095a059
27 QtWndProc@16 qapplication_win.cpp 1680 0x00952e73
28 USER32!IsWindowVisible C:\Windows\system32\user32.dll 0 0x777f86ef
29 ?? 0 0x00020362
30 ?? 0 0x00000240
31 USER32!IsWindowVisible C:\Windows\system32\user32.dll 0 0x777f8876
32 qt_is_translatable_mouse_event qapplication_win.cpp 1395 0x009520dd
33 USER32!IsWindowVisible C:\Windows\system32\user32.dll 0 0x777f89b5
34 ?? 0 0x00000000

Note:
The FingerPaint example that Qt provides works fine. I can draw with two finger everytimes (since my monitor only supports two simultaneous touches).

Now please enlighten me what going wrong here. I suspect that this issue is related to focus of the widgets.

Any pointers to further investigation or solution are appreciated.

Thanks

dpatel
2nd December 2010, 06:50
Update:

I have posted the response on another thread but in case someone finds the information useful.

I think I have found the cause of this issue but not sure if that's by design or a bug in QWidget.
As explained in above posts first time two widgets receive multi-touch events but after that only one widget receives touch events.
Usually Qt doesn't create separate native widgets for each widget that is placed upon main window (unless Qt::WA_NativeWindow attribute is set). It only creates one native widget and maintains child widgets. You can confirm this using Spy++ (which comes along with Visual Studio) or similar tool. I found that after the first touch/mouse event, Qt creates a native widget for the knob even if QCoreApplication::setAttribute(Qt::AA_DontCreateNa tiveWidgetSiblings) is done. So now if you touch that knobs it will grab the touch event and won't allow other knobs to receive simultaneous event.

I also made changes in QWidget::winID() and added following code
Qt Code:



if(QCoreApplication::testAttribute(Qt::AA_DontCrea teNativeWidgetSiblings)==false)
that->setAttribute(Qt::WA_NativeWindow);


instead of



that->setAttribute(Qt::WA_NativeWindow);



My changes fixes issue, and now I can move multiple knobs simultaneously more than once. Let me know if someone thinks that this might break something. Also let me know where can I post this issue so that Qt team can fix it or justify current behavior

Added after 57 minutes:

FYI:

This is a bug and is already reported to Qt team. You can track it at Qt-BugReport (http://bugreports.qt.nokia.com/browse/QTBUG-14004)