get Gestures in QWindow
-
I have a program with Qmainwindow as root. In Qmainwindow I created a MainWidget inherited from Qwidget, which acts like my layout. This MainWidget contains a Qwindow, where I draw opengl directly. Now I want that my Qwindow get gestures event, if I run my program on a window tablet.
Would I get gestures event in my MainWidget and can manually tell my Qwindow?
If not, can I create a transparent qwidget over my Qwindow and get gestures events?
Thanks in advance -
Hi,
IIRC if you want to handle gesture in widgets you should take a look at this chapter of Qt's documentation.
Hope it helps
-
Why about using your main window as a "proxy" to your QWindow ?
-
@SGaist
i tried but the Qmainwindow doesn't get the GestureEvents if i do it over the QWindow. I can confirm that QmainWindow does receive GestureEvent, if i perform gesture on another window like a QDockWindow, which also has Qmainwindow as parent.
Any suggestion is appreciated. Thanks -
By the way, why not use QOpenGLWidget rather than QWindow since you are using widgets anyway ?
-
@SGaist
I used all possibilities: QGLWidget, QOpenGLWidget, QOpenGLWindow and manually Qwindow+QOpenGlContext. The latter is much smoother and lightweight than others. I also have to use Qwindow.Another Question:
How do I get WM_GESTURE in nativeEvent? All I get are WM_Touch events.
There is no QNativeGestureEvent, too.Do you have any advices regarding following ideas:
- use a Qwidget in a new window and make it transparent. Overlap this window with over my application to get gesture.
- detect all needed gestures my myself from touch events
- try to get messages in WinPrc (my app is only for Windows).
Which way is the better one?
Thanks in advance -
What's WinPrc ?
For your ideas, what should your application do ?
-
@SGaist
i am thinking about monitoring windows message by myself to filter wm_gesture.
something like this:
https://ic3man5.wordpress.com/2012/04/29/monitoring-microsoft-windows-messages-using-qt-4-8/The development guideline for Touch Gesture on msdn.microsoft.com said, one can only get either WM_Touch or WM_Gesture. And it seems QT always get the WM_Touch events. I may have to unregister the app for getting touch events.
My app is a ported programm from old win32. it contains a main are, where i draw OpenGL on a QWindow by myself. now it should get multitouch features to manipulate the content.
-
I found out the solution using native Windows Gestures WM_Gesture.
By default QT registers QMainWindow-Window as a Touch Window, so the QMainWindow-App only get WM_Touch events.
As said above one can only get either WM_Touch event or WM_Gesture event. So you have to unregister the window from getting Touch event. I do that in the constructor like this:HWND myHwnd = reinterpret_cast<HWND>(this->winId()); PULONG flag = 0; bool istouch = IsTouchWindow(myHwnd,flag); if(istouch) UnregisterTouchWindow(myHwnd);
now i get WM_Gesture events in nativeEvent:
bool OpenGLWindow::nativeEvent(const QByteArray & eventType, void* message, long* result) { MSG* msg = reinterpret_cast<MSG*>(message); switch(msg->message){ case WM_GESTURE: case WM_GESTURENOTIFY: emit sendNativeEvent(eventType, message, result); break; } return false; }
Thanks for your help.