[Qt-qml] Why can't I stylesheet a font?

Alan Alpert alan.alpert at nokia.com
Tue Jul 13 06:30:37 CEST 2010


On Tue, 13 Jul 2010 10:48:46 ext Gregory Schlomoff wrote:
> I second that. Would be very useful to be able to create a predefined
> group of properties, and then assign the group as a whole to any
> object.
> 
> Something like this:
> 
> PropertyGroup {
>   id:bigText
>   font.face = "Arial"
>   font.pointSize: 30
>   color: "red"
> }
> 
> Text {
>   text:"Hello"
>   properties: [bigText, anotherSetOfProperties]
> }

Something also like that, but that you can do in QML today, is:

MyText.qml
Text{
	font.face: "Arial"
	font.pointSize: 20
	color: "red"
}
main.qml

MyText{
	text: "Hello"
}

This approach has the advantage of being linked to the type. This means that 
you only use the properties relevant for that type. Also the precedence is 
clear, so if you want to set a different color but keep the other properties, 
that's easy and should be unambiguous.

The downside of this approach is that you need an extra file, but presumably if 
these properties are worthwhile separating out you may want to use them in 
multiple files anyways. 

-- 
Alan Alpert
Software Engineer
Nokia, Qt Development Frameworks



More information about the Qt-qml mailing list