Shift the coordinates under Android when I use QML + c++.



  • Hi,

    I'm making a Qt 5.10 application for Windows, Linux, MacOS etc...
    I use in particular dialog boxes written in QML that I display using c++.

    for example this box:

    0_1516647251825_Sans titre2.png

    The C++ part:

    component_aideQML = new QQmlComponent (engine_configuration);
    component_aideQML->loadUrl (QUrl ("qrc: ///qml/help. qml");
    
    helpQML = qobject_cast<QQuickWindow*> (component_aideQML->create ());
    
    helpQML->setWidth (450);
    helpQML->setHeight (300);
    helpQML->setPosition (0.0,0.0.0);
    
    helpQML->setFlags (Qt:: WindowStaysOnTopHint | Qt:: FramelessWindowHint);
    
    helpQML->showNormal ();
    

    the QML part :

    import QtQuick 2.9
    import QtQuick.Window 2.3
    import QtQuick.Controls 2.2
    import QtQuick.Controls.Material 2.2
    import MyLib 1.0
    
    Window {
        id: main2
    
        property double trans: anchoraide.Trans
        property double coef: anchoraide.Coef
        property string texte: anchoraide.texte
    
        Material.theme: Material.Dark
        Material.accent: Material.Red
        modality: Qt.NonModal
    
        //visibility: Window.Windowed
        width: 450
        height: 300
        color: "#333333"
    
        opacity: trans
    
        Image {
            id: image_fermer
    
            width: 34
            height: 34
            anchors.top: parent.top
            anchors.topMargin: 0
            anchors.right: parent.right
            anchors.rightMargin: 0
            source: "../res/icons/fermer.png"
    
            MouseArea {
                anchors.fill: image_fermer
    
                onClicked: {
                    anchoraide.checkPost_command("exit")
                }
            }
        }   
        }
    
        Component.onCompleted: {
            visible = true
        }
    }
    

    Everything works fine if I use setPosition (0.0,0.0.0);
    when I press the red button, the checkPost_command ("exit") function in the MouseArea sends the "exit" text to the c++ part that allow to close the window...

    0_1516647925438_Sans titre.png

    On the other hand, everything changes if I use setPosition (0.0,200.0) for example.
    Clicking on the red button no longer sends the signal, but strangely enough, clicking 200 pixels below the red picture will close the window!
    It is as if the MouseArea had been translated by 200 + 200 pixels on the y-axis (see location of the black circle).

    Everything works normally on Windows, Linux and MacOS. The problem only appears with Android...

    How do we fix that?

    With my thanks,

    Francky033


  • Moderators

    @Francky033 If it's working with linux, osx, windows, but not android my guess is it's a bug in Qt/QML for android.

    I would search the bug reports, and if nothing is there, post a bug with the information you provided above.

    From just eyeballing it the QML and C++ all seem correct/valid. Maybe someone with more QML experience can comment. :)



  • thanks @ambershark !
    I've just posted a bug report


Log in to reply
 

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