Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84588

Missing touch events for QScrollArea

    XMLWordPrintable

Details

    • Linux/X11

    Description

      As title says. This was found in discussion ensured here about non-working kinetic scroll.

      Steps to reproduce:

      Build this code:

      // compile as: g++ test.cpp -o a -O0 -g3 -fPIC $(pkg-config --cflags --libs Qt5Gui Qt5Widgets)
      #include <QApplication>
      #include <QLabel>
      #include <QScrollArea>
      #include <QDebug>
      #include <QMetaEnum>
      
      void gen_label_text(QLabel& label) {
          const char sentence[] = "'th sentence here\n";
          QString text;
          for (int line = 0; line < 1e3; ++line) {
              text += QString::number(line) + sentence;
          }
          label.setText(text);
      }
      
      /// Gives human-readable event type information.
      // Credits to https://stackoverflow.com/a/22535470/2388257
      QDebug operator<<(QDebug str, const QEvent * ev) {
         static int eventEnumIndex = QEvent::staticMetaObject
               .indexOfEnumerator("Type");
         str << "QEvent";
         if (ev) {
            QString name = QEvent::staticMetaObject
                  .enumerator(eventEnumIndex).valueToKey(ev->type());
            if (!name.isEmpty()) str << name; else str << ev->type();
         } else {
            str << (void*)ev;
         }
         return str.maybeSpace();
      }
      
      struct QScrollAreaWrapper : public QScrollArea {
          bool event(QEvent* ev) override {
              qDebug() << "handling an event " << ev;
              return QScrollArea::event(ev);
          }
      };
      
      int main(int argc, char **argv) {
          QApplication app (argc, argv);
          QLabel label;
          gen_label_text(label);
          QScrollAreaWrapper qsa;
          qsa.setWidget(&label);
          qsa.show();
          // set Qt::WA_AcceptTouchEvents wherever possible
          label.setAttribute          (Qt::WA_AcceptTouchEvents, true);
          qsa.setAttribute            (Qt::WA_AcceptTouchEvents, true);
          qsa.viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
      
          return app.exec();
      }
      

      Run the application, do scroll with a touchpad, and look at the application output (it will print input events as they come).

      Expected:

      The output has "Touch" strings in it, like "TouchBegin", etc.

      Actual

      The output has no "Touch" strings, instead it has events like "HoverMove" and "Wheel".

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            srutledg Shawn Rutledge
            constantine2 constantine
            Votes:
            9 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes