-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.4.1, 5.7.0
-
Mac OS X 10.10.2
Windows
When Text element is placed inside ColumnLayout and it's text property is changed to string having different length, text gets drawn outside item's bounds.
Here's the example:
import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.1 ApplicationWindow { title: qsTr("Label Alignment Test") width: 300 height: 200 visible: true ColumnLayout { anchors.centerIn: parent Button { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Next") onClicked: _text.messageIndex += 1 } Text { id: _text readonly property var messages: [ qsTr("Loooooooong message"), qsTr("Short message") ] property int messageIndex: 0 horizontalAlignment: Text.AlignHCenter text: messages[messageIndex % messages.length] Rectangle { // Highlight text bounds anchors.fill: parent color: "#7fff0000" } } } }
When application starts, the long message is displayed, and everything is drawn correctly (semi-transparent red rectangle highlights actual bounds of the Text item):
When "Next" button is clicked the first time, long message is replaced with the short one, and text is shifted to the right, so that it partly resides beyond item's bounds:
After the second click on "Next" button message is switched back to short version, and now text is drawn to the left from where it should be:
Text alignment works fine if Column is used instead of ColumnLayout in the above example.
The attached ZIP archive contains the example project.
- duplicates
-
QTBUG-36873 Text is not aligned properly when resized
-
- Open
-