In QML, I want to fit some text into a limited amount of space. This text contains a localised, static and a variable part (a filename). The variable part is potentially too long to fit into the space I have and should be elided if that happens. The first part is allowed to wrap to a new line and being localised might do so or not.
My problem right now is the following: Both texts are in a Flow container, with the aim of appending the filename to the static text. However, if the first text part wraps, the whole text has the maximum width I have available and the filename will be put on a new line, even though the last line of the first part doesn't completely fill the space. See this image:
The code:
Flow {
width: parent.width
spacing: 4
Text {
width: (contentWidth <= parent.width) ? contentWidth : parent.width
text: qsTr("A string that might or might not wrap, depending on localisation")
wrapMode: Text.WordWrap
}
Text {
width: (contentWidth <= parent.width) ? contentWidth : parent.width
text: fileName
color: customColor
elide: Text.ElideMiddle
// ... more options
MouseArea {
anchors.fill: parent
onClicked: //stuff
}
}
}
Is it possible to use the remaining space of the last line?
EDIT: This is how it's supposed to look:

