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. Shift the coordinates under Android when I use QML + c++.

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

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 797 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 22 Jan 2018, 19:09 last edited by Francky033
    #1

    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

    A 1 Reply Last reply 22 Jan 2018, 21:46
    0
    • F Francky033
      22 Jan 2018, 19:09

      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

      A Offline
      A Offline
      ambershark
      wrote on 22 Jan 2018, 21:46 last edited by
      #2

      @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. :)

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Francky033
        wrote on 23 Jan 2018, 10:35 last edited by
        #3

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

        1 Reply Last reply
        1

        1/3

        22 Jan 2018, 19:09

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved