Multiline alignment with Linebreak
-
Hey ho.
I just wanted to know if (and how ;) ) it's possible to achieve a centered alignment with a text which includes an escape character.Here's what I got so far:
My goal is to have it something like
"Please use your RFID card or App to start the charging process"
Here*s my code so far:
Text{ id: idleText anchors.top: currentImage.bottom anchors.horizontalCenter: currentImage.horizontalCenter color: "white" anchors.topMargin: 60 text: qsTr("Please use your RFID card or App\nto start the charging process!") font.pointSize: 20 font.family: "Helvetica" }
I tried it with horizontal Alignment, and some other alignments, but I didn't find anything suitable. :(
-
anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter
does the job
Or alternatively you could constrain the width ot the Text and set wrapMode with horizontalAlignent also set to be responsive :
Text { text: qsTr("Please use your RFID card or App to start the charging process!") // no \n here font.pointSize: 20 width: parent.width padding: 60 horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap }
-
anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter
does the job
Or alternatively you could constrain the width ot the Text and set wrapMode with horizontalAlignent also set to be responsive :
Text { text: qsTr("Please use your RFID card or App to start the charging process!") // no \n here font.pointSize: 20 width: parent.width padding: 60 horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap }
@GrecKo Ah, thanks! That's awesome! Yeah, I think wrapping would be a bit cooler when it comes to localization!
Thanks a lot!