Results 1 to 3 of 3

Thread: Running text & slow drawText

  1. #1
    Join Date
    Aug 2009
    Posts
    6
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Arrow Running text & slow drawText

    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?
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Running text & slow drawText

    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...
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3

    Smile Re: Running text & slow drawText

    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.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. Why is drawText so terribly slow?
    By Ntoskrnl in forum Qt Programming
    Replies: 8
    Last Post: 1st August 2008, 20:15
  3. Text file parsing too slow
    By Potch in forum Newbie
    Replies: 5
    Last Post: 11th July 2008, 22:16
  4. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 13:05
  5. Drawing antialiased text on Windows very slow
    By Rawk in forum Qt Programming
    Replies: 13
    Last Post: 14th May 2007, 15:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.