Search code examples
qtqmlqt-quick

QML: set smooth painting


While playing with QML I noticed a strange behavior. Let's say I have simple QML code:

Rectangle {
    anchors.centerIn: parent
    width:200
    height:100
    color:"yellow"
    border.color: "green"
    border.width: 10
    rotation: 190    
}

And the result:

not smoothed rectangle

The image looks poor, especially the border. But if I add radius: 1 I get a very different picture:

smoothed rectangle

Now it looks much better. the border also looks more smoother. Btw, setting smooth property do nothing. It looks that setting radius switches on some internal smoothing. So my question - how can I set this smooth without setting radius?

I use Qt 5.4 on Debian 7


Solution

  • The property you need to set is antialiasing. This is documented here:

    antialiasing : bool

    Used to decide if the Rectangle should use antialiasing or not. Antialiasing provides information on the performance implications of this property.

    The default is true for Rectangles with a radius, and false otherwise.

    (Emphasis mine.)