Avoid using painter paths. And if you don't want to, optimise your code. For instance construct the path once and not every time paintEvent is called. The speedup probably won't be very significant, but you have to start with something...
Avoid using painter paths. And if you don't want to, optimise your code. For instance construct the path once and not every time paintEvent is called. The speedup probably won't be very significant, but you have to start with something...
Try this (You may have to adjust the font name). Is it very unacceptable?
Your example works fine, but it draws only one word. Just change the source a little bit to draw a little bit more and you'll see the difference.
I've made the font a little bit smaller and replaced
withQt Code:
path.addText(0, 96, fnt, txt);To copy to clipboard, switch view to plain text mode
Use a static color for the brush (otherwise the difference is not so big...). Then let the program draw 6 or more lines of text on Linux and on Windows. On Windows it needs a few seconds. Because my application often has to draw outlined text, I need some faster solution although it is drawn once on a QPixmap. Thanks for trying to help even though I still have no solution.Qt Code:
int lineHeight = fontMetrics.height(); int y = 0; { path.addText(0, y, fnt, line); y += lineHeight; }To copy to clipboard, switch view to plain text mode
I still think you shouldn't use a painter path at all. It's just unreliable for objects where you can't estimate their complexity upfront. And if you do insist on using it - do it once and try to keep the number of nodes in it as small as possible.
I don't care whether I use a painter path or not. I just need to draw outlined text in an acceptable time.
Bookmarks