How to center text in Label?

  • 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"

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

  • @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

Log in to reply