Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. get Gestures in QWindow
Forum Updated to NodeBB v4.3 + New Features

get Gestures in QWindow

Scheduled Pinned Locked Moved General and Desktop
qwindowgestures
10 Posts 2 Posters 4.3k Views 2 Watching
  • 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 Offline
    X Offline
    Xv1nX
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • SGaistS SGaist

        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

        X Offline
        X Offline
        Xv1nX
        wrote on last edited by
        #3

        @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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0
          • SGaistS SGaist

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

            X Offline
            X Offline
            Xv1nX
            wrote on last edited by
            #5

            @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
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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
              0
              • SGaistS SGaist

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

                X Offline
                X Offline
                Xv1nX
                wrote on last edited by
                #7

                @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
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  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
                  0
                  • SGaistS SGaist

                    What's WinPrc ?

                    For your ideas, what should your application do ?

                    X Offline
                    X Offline
                    Xv1nX
                    wrote on last edited by
                    #9

                    @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
                    0
                    • X Offline
                      X Offline
                      Xv1nX
                      wrote on last edited by
                      #10

                      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
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved