Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Strange problem with MouseArea under Android

Strange problem with MouseArea under Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 568 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.
  • F Offline
    F Offline
    Francky033
    wrote on last edited by Francky033
    #1

    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
    
    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