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. QML - Qt 6.4.1 - Android 10 - Wrong Text/Label alignment

QML - Qt 6.4.1 - Android 10 - Wrong Text/Label alignment

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

    Hi,

    I am working on a smart home dashboard in Qt (QML) that should run in Linux or Android tablet.

    Currently I have an issue in android: The verticalAlignment doesn't seems to be used to render the QML.

    Here is my QML:

    Rectangle {
    	color: 'transparent'
    	Layout.fillHeight: true
    	Layout.fillWidth: true
    	Layout.columnSpan: 1
    	Layout.rowSpan: 1
    	Layout.row: 2
    	Layout.column: 0
    
    	GridLayout {
    		anchors.fill: parent
    		flow: GridLayout.TopToBottom
    
    		Rectangle {
    			color: 'transparent'
    			Layout.fillWidth: true
    			Layout.fillHeight: true
    
    			Label {
    				color: Constants.fontColorBold
    				anchors.fill: parent
    				text: "65%"
    				font.pixelSize: 40
    				horizontalAlignment: Text.AlignHCenter
    				verticalAlignment: Text.AlignBottom
    				font.styleName: "Bold"
    			}
    		}
    
    		Rectangle {
    			color: 'transparent'
    			Layout.fillWidth: true
    			Layout.fillHeight: true
    
    			Label {
    				color: Constants.fontColor1
    				anchors.fill: parent
    				text: "Humidity"
    				font.pixelSize: 40
    				horizontalAlignment: Text.AlignHCenter
    				verticalAlignment: Text.AlignTop
    				font.styleName: "Light"
    			}
    		}
    	}
    }
    

    The label "65%" must appear vertically aligned to bottom
    The label "Humidity" must appear vertically aligned to top

    In Linux: It's correctly displayed
    In Android: it's centered vertically (bottom/top doesn't take effect)

    Any help will be appreciated

    1 Reply Last reply
    0
    • TomZT Offline
      TomZT Offline
      TomZ
      wrote on last edited by
      #2

      Have you tried simply aligning the label itself instead of the text inside the label?

      So, instead of your Label you'd write;

      Label {
          color: Constants.fontColorBold
          anchors.right: parent.right
          anchors.bottom: parent.bottom
          text: "65%"
          font.pixelSize: 40
          font.styleName: "Bold"
      }
      
      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