Hi Bo, Maybe what you need is a variation (for single-line texts) of what I tried to ask for here https://bugreports.qt.nokia.com/browse/QTBUG-16665
But at the time I couldn't come up with a concrete example so the suggestion was closed as incomplete. Perhaps you can add your use case to the above posting. Cheers Mathias ________________________________________ From: [email protected] [[email protected]] on behalf of ext Bo Thorsen [[email protected]] Sent: Tuesday, September 06, 2011 9:08 AM To: [email protected] Subject: [Qt-qml] Text eliding I'm trying to ellide a text item, but it's proving quite complicated. I'm tempted to implement my own C++ based QML class that does this, but it just seems silly. The problem is that Text says it can only elide when you have set the width, but I don't have that. I have something like this: Item { width: parent.width anchors.centerIn: parent Text { id: text1 text: ... elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter font.bold: true } Text { id: text2 text: .... } } (most anchors and stuff like that has been omitted) So I want text1 to elide on the right side, when the combined text of the two doesn't fit in the row. What I actually have here is a max width which is parent.width - text2.width. In HTML, it would look like this: "<center><bold>text1</bold>text2</center>", except that text1 should be elided. It might be that there is a way to set something like this on the text2 width: width: max(font.textWidth(text), parent.width - text2.width) But I haven't been able to figure out how to do that. Any good ideas? Bo Thorsen, Fionia Software. -- Expert Qt and C++ developer for hire Contact me if you need expert Qt help http://www.fioniasoftware.dk _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
