Four-finger swipe on iPad



  • 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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.