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. touch event in qml does not propagate to its parent qquickwidget
Forum Updated to NodeBB v4.3 + New Features

touch event in qml does not propagate to its parent qquickwidget

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 864 Views 1 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.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #1

    A QML widget is embedded in a qt widgets app. On touch screen, mouse event is received in case mouse is pressed. But touch event is not converted to mouse event.
    How to get touch event in QQuickWidget from its source qml?

    Qt: 5.15.3 and LUbuntu 22.04.

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      Has overriding QObject::event() to handle QEvent::Touch(Begin|CancelEnd|Update) been tried?

      Asking a question about code? http://eel.is/iso-c++/testcase/

      JoeCFDJ 1 Reply Last reply
      0
      • jeremy_kJ jeremy_k

        Has overriding QObject::event() to handle QEvent::Touch(Begin|CancelEnd|Update) been tried?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        @jeremy_k Tried it and saw touchBegin there. But I can not use it because it will make my app very slow.

        jeremy_kJ 1 Reply Last reply
        0
        • JoeCFDJ JoeCFD

          @jeremy_k Tried it and saw touchBegin there. But I can not use it because it will make my app very slow.

          jeremy_kJ Offline
          jeremy_kJ Offline
          jeremy_k
          wrote on last edited by
          #4

          @JoeCFD said in touch event in qml does not propagate to its parent qquickwidget:

          @jeremy_k Tried it and saw touchBegin there. But I can not use it because it will make my app very slow.

          Please elaborate. Is overriding QObject::event() making it slow, the program's access patterns for the touch events, or something else?

          Asking a question about code? http://eel.is/iso-c++/testcase/

          JoeCFDJ 1 Reply Last reply
          0
          • jeremy_kJ jeremy_k

            @JoeCFD said in touch event in qml does not propagate to its parent qquickwidget:

            @jeremy_k Tried it and saw touchBegin there. But I can not use it because it will make my app very slow.

            Please elaborate. Is overriding QObject::event() making it slow, the program's access patterns for the touch events, or something else?

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #5

            @jeremy_k Yes, the override of QObject::event() makes my app slow. I have managed to solve the issue by adding a signal pressed() in the qml code and connecting to qquickwidget. But this should not be needed.

            JoeCFDJ 1 Reply Last reply
            0
            • jeremy_kJ Offline
              jeremy_kJ Offline
              jeremy_k
              wrote on last edited by jeremy_k
              #6

              The signal sounds very convenient, not necessary, and surprising that it is faster than overriding event() ... unless the signal is emitted by an Item at the top of a very deep stack, circumventing delivery to lots of items that will ignore it. Event handling is how large swaths of Qt Widgets and Quick item implementations work.

              I'm presuming that the implementation is something like:

              bool MyClass::event(QEvent *ev)
              {
                  switch(ev->type()) {
                  case QEvent::TouchBegin:
                      qDebug() << "touch started";
                      break;
                  default:
                      return ParentClass::event(ev);
                  }
                  return true;
              }
              

              Asking a question about code? http://eel.is/iso-c++/testcase/

              JoeCFDJ 1 Reply Last reply
              0
              • jeremy_kJ jeremy_k

                The signal sounds very convenient, not necessary, and surprising that it is faster than overriding event() ... unless the signal is emitted by an Item at the top of a very deep stack, circumventing delivery to lots of items that will ignore it. Event handling is how large swaths of Qt Widgets and Quick item implementations work.

                I'm presuming that the implementation is something like:

                bool MyClass::event(QEvent *ev)
                {
                    switch(ev->type()) {
                    case QEvent::TouchBegin:
                        qDebug() << "touch started";
                        break;
                    default:
                        return ParentClass::event(ev);
                    }
                    return true;
                }
                
                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #7

                @jeremy_k It is faster because it sends out signal only when touch events occur.
                bool MyClass::event(QEvent *ev) will be called many times.

                1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @jeremy_k Yes, the override of QObject::event() makes my app slow. I have managed to solve the issue by adding a signal pressed() in the qml code and connecting to qquickwidget. But this should not be needed.

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by
                  #8

                  @JoeCFD the problem is solved. But there may be better solutions. I will mark it as solved.

                  1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD has marked this topic as solved on

                  • Login

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