Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to centre align Items under Column



  • Hi

    I am trying to centre align the text fields Under QML Column as shown below , but the text fields are always left aligned

     Column {
     
      Text { text: "1" }
      Text { text: "2" }
     
    }
    

    f2faf8d8-d759-4833-aa2e-f2712ad9397d-image.png

    Regards,
    James A



  • Add anchors.horizontalCenter: parent.horizontalCenter to each of your text items and add width: parent.width to Column

            Column {
                width: parent.width
                Text { text: "1"; anchors.horizontalCenter: parent.horizontalCenter }
                Text { text: "2"; anchors.horizontalCenter: parent.horizontalCenter }
            }
    


  • @Markkyboy

    Thanks for helping out. This helped me to fix the problem

    53bef655-1d11-4b02-9129-d3ec4ff8e2ce-image.png


Log in to reply