Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
5.7.0
-
None
Description
If a button shrinks after growing due to text length changes, the text will be displayed further to the right. Oddly the text item position is correct, but the text is rendered centred on its previous width (it appears moved to the right).
If text alignment is set to Text.AlignLeft, the text is positioned correctly, with Text.AlignHCentre (default) and Text.AlignRight does not.
If the text is changed again (even in something still smaller than the default button size), it renders correctly again.
Button { // ok -> ok -> ok -> ok -> ok -> bad -> bad -> ok property var ts: ["##","####","########","############","########################","############","########","####"] property int count: 0 text: ts[count] onClicked: count = (count + 1) % ts.length //growth direction doesn't matter at all //anchors.right: parent.right //anchors.margins: 150 Rectangle { anchors.fill: parent.contentItem color: "red" opacity: 0.125 } //componentItem is a Text Component.onCompleted: { //renders correctly //contentItem.horizontalAlignment = Text.AlignLeft //renders further to right //contentItem.horizontalAlignment = Text.AlignRight } }
Attachments
Issue Links
- duplicates
-
QTBUG-50740 Button: mis-aligned text
-
- Closed
-