> On 17 Nov 2015, at 19:32, Jason H <jh...@gmx.com> wrote:
> 
> I want to fit text into a rectangle, but dynamically size the text like 
> scaling an image:
> Rectangle {
> width: // some with
> width: // some height
> Text { text: "Hello World"; anchors.fill: parent; font.pixelSize: 
> ???<Dynamic> }
> }

See Text::fontSizeMode: 
http://doc.qt.io/qt-5/qml-qtquick-text.html#fontSizeMode-prop

> In the old QWidget days, I'd use QFontMetrics to figure out what size would 
> fit. Has this been solved for QML? 

There’s also FontMetrics (http://doc.qt.io/qt-5/qml-qtquick-fontmetrics.html) 
and TextMetrics (http://doc.qt.io/qt-5/qml-qtquick-textmetrics.html) in QML, 
but Text::fontSizeMode does the job for you.

--
J-P Nurmi

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to