Saturday, April 17, 2010

Change the scale of QML text

Using transform property and Scale element, we can change the scale of QML text.
import Qt 4.7

Rectangle {
    width: 200
    height: 200
    Text {
        id: original
        x: 60
        y: 80
        text: qsTr("Hello World")
    }
    Text {
        x: original.x
        y: original.y + 16
        text: original.text + "!"
        font {
            family: "Helvetica"
            pointSize: 12
            italic: true
        }
        color: "blue"
        transform: Scale {
            xScale: 1.25
            yScale: 5
        } // change the scale of this text item
    }
}
But this font is dirty. Then let's be smooth.
        transform: Scale {
            xScale: 1.25
            yScale: 5
        } // change the scale of this text item
        smooth: true // smooth the transformation of this text
Re-run the QML application:

No comments:

Post a Comment