[Development] Styling Qt Quick Items

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Thu Apr 24 14:44:40 CEST 2014


On 24 Apr 2014, at 00:57, Alex Montgomery <apmontgomery at gmail.com<mailto:apmontgomery at gmail.com>> wrote:

Hello,

While trying to style a ComboBox such that its text didn't elide and it didn't have inexplicably large margins, I was surprised to learn that these two items would be displayed entirely differently:

ComboBox { model: ["1", "2"] }
ComboBox { model: ["1", "2"]; style: ComboBoxStyle{} }

Which leads me to these questions:
- Is there a reason that a default constructed ComboBoxStyle (and other Qt Quick style types) is not identical to the style of default constructed ComboBox?

When you style the control you basically take complete control of it’s looks. It is extremely hard to maintain partial fallbacks to native looks when some things are touched and others are not and the visual result tend to depend on the platform you run it on.

To get an idea, the only thing that is vaguely supported and working well this way in widget style sheets is setting the text foreground colour. Pretty much anything else will force the style sheet to draw the widget as a Windows 95 control as a common fallback on all platforms. Most native styles draw controls using pixmaps and cannot be tweaked and modified in any useful way without completely replacing the original styling.

When you actually do a custom theme, it is more reliable to have a consistent appearance path on all platforms which is what the base style does. I think the real issue here is why the native control is not eliding in the first place, so fixing that would be the preferred solution. This is probably QStyle/platform specific and should be filed as a separate issue.

- Is there a way for someone to define their own style that subtly tweaks the default style without digging through Qt source code to find the actual default properties?
I think the style classes would be far more useful if users could define individual properties that they wanted to change without having to specify every other property to match the (undocumented) properties set by the ComboBox constructor.

I think the idea of tweaking existing native styles without replacing them would be better solved by applying an object containing style hints that can be respected or not depending on the platform you run on. That way I imagine you would be able to set properties like “text-color”, “background” or “border-type" property and allow the style to respect it if and only if it is actually supported. We have a plan on supporting this through the “stylehints: property but we have currently not yet determined exactly how inheritance or selectors should be applied.

Regards,
Jens

Regards,
Alex
_______________________________________________
Development mailing list
Development at qt-project.org<mailto:Development at qt-project.org>
http://lists.qt-project.org/mailman/listinfo/development

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140424/2a1d8a29/attachment.html>


More information about the Development mailing list