[Interest] How to change QFont::StyleStrategy from QML?

Bo Thorsen bthorsen at ics.com
Mon Jan 20 12:18:16 CET 2014


Den 19-01-2014 14:49, ElderOrb skrev:
> I have a font which is unfortunately rendered incorrectly unless
> QFont::StyleStrategy set to QFont::NoFontMerging. This font is being
> loaded via QML Loader and used by many QML controls. Unfortunately
> 'QFont::NoFontMerging' is not exposed to QML so I can't change it like the
> other font settings. Is there any others ways to set this flag than
> creating my own QML wrapper over QFont and passing this QFont to all the
> QML elements?

This really shouldn't happen. There's a bug in either the font or the Qt 
code. You are going to have to do the workaround, unfortunately.

However, it's usually a good idea to centralize things like font, colors 
etc in a style sheet like object. Then you at least only have to do this 
once.

Whether you do this in a javascript file (remember to mark it as a 
library), a QML object or an exported C++ object, the idea is the same. 
Make a single object that has a property for each of them and bind your 
text etc to the font property.

Bo.

-- 
Bo Thorsen, European Engineering Manager, ICS
Integrated Computer Solutions. Delivering World-Class Applications
http://ics.com/services



More information about the Interest mailing list