Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    get Gestures in QWindow

    General and Desktop
    qwindow gestures
    2
    10
    3411
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      Xv1nX last edited by

      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

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        X 1 Reply Last reply Reply Quote 0
        • X
          Xv1nX @SGaist last edited by

          @SGaist
          Thanks for your reply, but i am not sure how to get gesture events to my QWindow, since QWindow is not support QGesture.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Why about using your main window as a "proxy" to your QWindow ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            X 1 Reply Last reply Reply Quote 0
            • X
              Xv1nX @SGaist last edited by

              @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

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                By the way, why not use QOpenGLWidget rather than QWindow since you are using widgets anyway ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                X 1 Reply Last reply Reply Quote 0
                • X
                  Xv1nX @SGaist last edited by

                  @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

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    What's WinPrc ?

                    For your ideas, what should your application do ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    X 1 Reply Last reply Reply Quote 0
                    • X
                      Xv1nX @SGaist last edited by

                      @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.

                      1 Reply Last reply Reply Quote 0
                      • X
                        Xv1nX last edited by

                        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.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post