QPainter::drawText cost 500ms to run
-
Hi, all
I have a problem. I use QPainter::drawText in QWidget::paintEvent. But, after I set font, the drawText function will cost about 500ms to run at the first time. Then it runs quickly , less then 5ms.
I use drawText(const QRect & rectangle, int flags, const QString & text, QRect * boundingRect = 0).
Qt version 5.9.6So, please help me. How can I draw text normal quickly.
-
QPainter::drawText cost 500ms to run
Then it runs quickly , less then 5ms.Is it 5ms or 500ms you are claiming? There's quite a difference....
OIC, you mean 500ms first time and then 5ms. Got it.
Could it be first load of a particular font?? -
I just use C:\Windows\Fonts\msyh.tff font and set QFont::setPixelSize(25).
If I don't set font, 'drawText' run fast. I don't know why.
I have searched the solution for a week now, but I have no result.
I used 5.9.0 before, and I update to 5.9.6 today. But don't fix it -
Try adding the font to the database in advance: http://doc.qt.io/qt-5/qfontdatabase.html#addApplicationFont