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. Qml android a icon is above the button
Forum Updated to NodeBB v4.3 + New Features

Qml android a icon is above the button

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 526 Views 1 Watching
  • 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.
  • JobRecrdJ Offline
    JobRecrdJ Offline
    JobRecrd
    wrote on last edited by JobRecrd
    #1

    I can't figure out why the icon comes out of the button on one of the devices. Everything works as expected on the Nexus 4, but some magic happens with the Nexus 6.
    Nexus 6.
    Nexus6.png
    Nexus 4.
    Nexus4.png

    RowLayout {
            id:rlWsd
            anchors.left: window.left
           anchors.top: window.top
    Rectangle {
           anchors.left: rlWsd.left
           implicitWidth: 40
           implicitHeight: 40
           border.color: "red"
              Button {
                         id: bthup
                         icon: icons.fa_apple
                         font.pointSize : 15
                                        }
    }
    }
    
    ODБOïO 1 Reply Last reply
    0
    • JobRecrdJ JobRecrd

      I can't figure out why the icon comes out of the button on one of the devices. Everything works as expected on the Nexus 4, but some magic happens with the Nexus 6.
      Nexus 6.
      Nexus6.png
      Nexus 4.
      Nexus4.png

      RowLayout {
              id:rlWsd
              anchors.left: window.left
             anchors.top: window.top
      Rectangle {
             anchors.left: rlWsd.left
             implicitWidth: 40
             implicitHeight: 40
             border.color: "red"
                Button {
                           id: bthup
                           icon: icons.fa_apple
                           font.pointSize : 15
                                          }
      }
      }
      
      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      @JobRecrd said in Qml android a icon is above the button:

      RowLayout {
      id:rlWsd
      anchors.left: window.left
      anchors.top: window.top
      Rectangle {
      anchors.left: rlWsd.left //<< dont use anchors here

      You are using anchors in an item managed by QML Layout, that can lead to undefined behavior, there must be a warning in your application output in QtCreator

      JobRecrdJ 1 Reply Last reply
      0
      • ODБOïO ODБOï

        @JobRecrd said in Qml android a icon is above the button:

        RowLayout {
        id:rlWsd
        anchors.left: window.left
        anchors.top: window.top
        Rectangle {
        anchors.left: rlWsd.left //<< dont use anchors here

        You are using anchors in an item managed by QML Layout, that can lead to undefined behavior, there must be a warning in your application output in QtCreator

        JobRecrdJ Offline
        JobRecrdJ Offline
        JobRecrd
        wrote on last edited by
        #3

        @LeLev
        I removed the anchor, but it didn't help, the problem remained.

        ODБOïO 1 Reply Last reply
        0
        • JobRecrdJ JobRecrd

          @LeLev
          I removed the anchor, but it didn't help, the problem remained.

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @JobRecrd i'm not sure what is wrong then,
          try to explicitly center your button in the rectangle maybe..

          Button{
            anchors.centerIn:parent
          }
          
          1 Reply Last reply
          0
          • MarkkyboyM Offline
            MarkkyboyM Offline
            Markkyboy
            wrote on last edited by
            #5

            If you are not tied to using RowLayout, try using just Row instead and drop some of the anchors (pun intended!), you could also lose the Button in exchange for a MouseArea to control the icon;

            Here's one way;

            import QtQuick 2.12
            import QtQuick.Window 2.12
            import QtQuick.Controls 2.12
            
            Window {
                visible: true
                width: 540
                height: 960
                title: qsTr("Apple")
            
                Row {
                    id: rowOne; x: 20; y: 20
                    Rectangle {
                        id: rect; width: 100; height: width
                        border.color: "red"; border.width: 2
                        Image { source: "apple.png"; anchors.centerIn: parent }
                        MouseArea {
                            anchors.fill: parent
                            onEntered: {
                                rect.border.width = 4
                                rect.border.color = "black"
                            }
                            onExited: {
                                rect.border.width = 2
                                rect.border.color = "red"
                                console.log("How d'ya like them apples?")
                            }
                        }
                    }
                }
            }
            
            

            apple-screenshot.JPG

            Don't just sit there standing around, pick up a shovel and sweep up!

            I live by the sea, not in it.

            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