M
M
Mercury132021-06-24 13:01:28
Qt
Mercury13, 2021-06-24 13:01:28

How lightweight is QFont?

Does it make sense to create objects of type QFont every minute every time you need to display something - using the QFont(family, size) constructor? Or, on the contrary, should they be cached?
The same for QFontMetrics.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2021-06-24
@Mercury13

Well, yes, you can create every time, judging by

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.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question