PDA

View Full Version : Running text & slow drawText



KL-7
10th August 2009, 07:24
Hi.
I want to implement a running text line for typing trainer. I need it to be smooth, so I cant use QLineEdit and move text by one character.
So I wrote my own widget which draw text with QPainter::drawText and move every character aproximately in 10 steps with 10 milisecond interval.

It works quite good, but drawText seems to be a quite slow operation.
When I use 35 font size it works perfect, but when I use smth like 55-75 (the text to draw become bigger) my widget cant keep pace with me (I type about 60wpm) on my old computer (and CPU usage jump from 20% to 98%).

So I need to make it faster. Are there any better (faster) ways to draw text?

faldzip
10th August 2009, 16:29
maybe you can extend your interval to even 40ms as it gives 25 frames which should be enough for human eye to see smooth transformation. Whats more your OS (Windows in this case) can't even be so accurate to call your slot every 10ms - i suppose it can be rather 12-16ms or even more. So check if 4 steps with 25ms interval is satisfying you and if the CPU load is lower.
These are my general hints, I did not take a look in your code yet...

robertkun
11th August 2009, 11:24
I have a look at you program .That's cool .
Last month I had write a program use the QGraphicsTextItem ,
When I input many letters in it ,the Paint is slow.
So I reWiter the paint of the QGraphicsTextItem ,
you can have a try also.Only draw the view area.