Tanks anda_skoa,
I was hoping to save time and avoid debugging Qt, but...
Here is what I found:
QFont holds an internal shared data object of QFontPrivate following Qt's shared data object scheme (pattern). QFontPrivate has members called:
QFontDef request;
mutable QFontEngineData *engineData;
QFontDef request;
mutable QFontEngineData *engineData;
To copy to clipboard, switch view to plain text mode
Which seem to be related to the internal font support involving classes like QFontCache, QFontEngineData, QFontData, QFontDef, etc. Those suppose caching of objects through object maps - which is mentioned in the documentation as well:
Loading fonts can be expensive, especially on X11. QFont contains extensive optimizations to make the copying of QFont objects fast, and to cache the results of the slow window system functions it depends upon.
But the above are all internals.
Therefore the only optimization one can do is saving unnecessary QFontPrivate object creation. This is to save creating two identical instances - one for each line in case of following constructor:
QFont f1("Arial", 18);
QFont f2("Arial", 18);
To copy to clipboard, switch view to plain text mode
One shall decide how to proceed and if this kind of light optimization deserves the efforts.
Bookmarks