I don't want to toot my own horn, but we were discussing that with another developer a while ago on the chat, and it would definitely be very helpful to have a simple and flexible way to assign properties in batches.
The "subclassing" method (making a separate component) is not flexible enough when you have multiple combinations of styles, and can quickly lead to a nightmare of files. > This approach has the advantage of being linked to the type. This means that > you only use the properties relevant for that type When you create a PropertyChanges element, you also lose type information, so it doesn't seem to be that much of an issue. So yes, this is probably not something that is going to be introduced in 4.7, but my guess is that as the usage of QML increases, the need for something like property groups will really become obvious. Cheers, greg On Tue, Jul 13, 2010 at 11:37 AM, Jason H <[email protected]> wrote: > Actually I like Gregory's better still. While I'd likely put the "style sheet" > stuff in a separate file, your implementation implies that I'd have to have a > file for every item of every style. HTML CSS's files can be one per site, and > that's a huge feature. > > And the fact that I can specify font and color (which isn't a part of font!?) > at the same time is really handy. > > > Still, good to know... > > > ----- Original Message ---- > From: Alan Alpert <[email protected]> > To: [email protected] > Sent: Tue, July 13, 2010 12:30:37 AM > Subject: Re: [Qt-qml] Why can't I stylesheet a font? > > 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 > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.trolltech.com/mailman/listinfo/qt-qml > > > > > > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.trolltech.com/mailman/listinfo/qt-qml > _______________________________________________ Qt-qml mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-qml
