Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved How to center text in Label?

    QML and Qt Quick
    3
    3
    797
    Loading More Posts
    • 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.
    • P
      Pyroxar last edited by

      How to center text in Label?

      Label {
                      Layout.topMargin: 50
                      Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
                      Layout.fillWidth: true
                      text: "Vivamus pulvinar neque sit amet tellus ultrices, sit amet tempor diam mollis"
                      wrapMode: Text.WordWrap
                      font.pixelSize: 16
                      color: "#424242"
                  }
      
      E Yashpal 2 Replies Last reply Reply Quote 0
      • E
        Eeli K @Pyroxar last edited by

        @Pyroxar Label extends the Text type which has horizontalAlignment property.

        1 Reply Last reply Reply Quote 0
        • Yashpal
          Yashpal @Pyroxar last edited by

          @Pyroxar You can try something like this. And, I hope this is what you were looking for.

          Label {
              text: "Some Text"
              wrapMode: Text.WordWrap
              horizontalAlignment: Text.AlignHCenter
              verticalAlignment: Text.AlignVCenter
          }
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post