TextMetrics elideWidth is not working propertly on Android
-
I created a component with Text and TextInput and I wanted to elide the text of TextInput using TextMetrics however, it didn't work because I am getting 0 width from its parent.
PS: this only happened in Android, while in iOS it is working fine.
Item { id: comp implicitWidth: parent.width RowLayout { anchors { left: parent.left; right: parent.right } Text { id: label } ColumnLayout { Layout.fillWidth: true TextInput { id: input Layout.fillWidth: true Layout.preferredWidth: implicitWidth - 2 } TextMetrics { elideWidth: input.width - 10 } Rectangle { id: recLine Layout.fillWidth: true height: 3 } } } }
My problem is eliding of text didn't work because the input.width returns 0.
Any advise how to get the dynamic width of the textInput to set it TextMetrics elideWidth?
Is there a way that the TextMetrics will be created only after the TextInput?Thanks.
UPDATE:
*** I tried explicitly set the elideWidth, it turned out that the TextInput.width - 10 is still longer than the textinput width, that is why it didn't elide the text. How did it happened?
However in iOS, TextInput.width - 10 is already enough to elide the text.