Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Four-finger swipe on iPad
Qt 6.11 is out! See what's new in the release blog

Four-finger swipe on iPad

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 924 Views
  • 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.
  • P Offline
    P Offline
    Phuoc Nguyen
    wrote on last edited by
    #1

    Dear all experts!
    I am developing an application for Android/iOS.
    I am using MouseArea to make my button.
    I am stuck in the following case:
    Touch on screen with 4 fingers, 1 finger among them touch on the button.
    Swipe the screen.
    The application become inactive state. I display a item as a popup (the button will go into disable state) when the application become active state again. Then the popup will be hidden, the button is enable state.
    Now the button doesn't receive mouse event again.
    Are there any hint?
    Thanks you for help
    Best regards

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Phuoc Nguyen
      wrote on last edited by Phuoc Nguyen
      #2

      Luckily, I can resolve my problem. I override notify method of QGuiApplication:

      bool MyApplication::notify(QObject *receiver, QEvent *event){
          QEvent::Type t = event->type();
          switch(t){
          case QEvent::MouseButtonPress:
              lastReceiver = receiver;
              break;
          case QEvent::MouseButtonRelease:
              lastReceiver = NULL;
              break;
          case QEvent::ApplicationStateChange:
              //To background
              if (lastReceiver != NULL){
                  QQuickItem*item = qobject_cast< QQuickItem*>(lastReceiver);
                  if (item != NULL){
                      if(QGuiApplication::applicationState() == Qt::ApplicationInactive){
                          item ->ungrabMouse();
                      }
                      if(QGuiApplication::applicationState() == Qt::ApplicationActive ){
                          item ->grabMouse();
                          lastReceiver = NULL;
                      }
                  }
              }
      
              break;
          default:
              break;
          }
          return QGuiApplication::notify(receiver,event);
      }
      
      

      In the above piece of code, lastReceiver is a private variable. It is used to keep the last mouse pressed event object

      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