Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Strange problem with MouseArea under Android



  • I had already reported this problem on the bug track but it had no effect: https://bugreports.qt.io/browse/QTBUG-65927

    I get a strange result under Android when I use MouseArea in QML boxes.

    Clicking on buttons works perfectly well when the box is placed at coordinates (0, 0) but it doesn't work anymore when the QML box is placed at any coordinates.

    If a button is placed at the coordinates (100,50) in the QML box and this box is at the coordinates (150,50) of the screen, then It is as if the upper left edge of MouseArea is located at the coordinates (400,150) instead of at the coordinates (150+100, 50+50) =(250,100).
    This is similar to the MouseArea having been translated by 2 * (150, 50).

    On the other hand, everything works perfectly well under Windows, linux and macOS.

    The QML box is displayed correctly at the coordinates (150, 50).

    Is there a bug in the Android version or did I forget something?

    I'm using Qt 5.15.2

    Thanks !

    Francky033

    Here is the code :

    cpp part :

    engine_configuration->rootContext()->setContextProperty("anchorMenuAndroid", anchor_menu_androidQML);
    component_menu_androidQML = new QQmlComponent(engine_configuration);
    component_menu_androidQML->loadUrl(QUrl("qrc:///qml/menu_android.qml"));
    
    if (component_menu_androidQML->isReady())
    {
        menuAndroidQML = qobject_cast<QQuickWindow*>(component_menu_androidQML->create());
        menuAndroidQML->ShowNormal();
        menuAndroidQML->setPosition(QPoint(150, 50));
    }
    else
       qWarning() << component_menu_androidQML->errorString();
    

    QML box

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.15
    import MyLib 1.0
    
    Window {
        id: main2
    
        modality: Qt.NonModal
    
        width: 250
        height: 250
        color: "#000000"
        visible: true
    
        x: 0
        y: 0
    
        Item {
            anchors.fill: parent
    
            Button {
                id: image1
                x: 100
                y: 50
                width: 100
                height: 100
                text: "Test"
             
                MouseArea {
                    anchors.fill: parent
    
                    onClicked: {
                        console.log("test")
                    }
                }
            }
        }
    }
    

    Warnings:

    D ViewRootImpl@6fe002a[QtActivity]: ViewPostIme pointer 0
    D ViewRootImpl@6fe002a[QtActivity]: ViewPostIme pointer 1
    

Log in to reply