Drawing text on the screen?

  • I need to draw graphics and text on the screen. I've googled a bit and people recommended using a transparent widget in which I could override the paintEvent, and so I did, the problem is that I need the things drawn to sometimes move around on the screen relatively fast and that results in stuff like text becoming very hard to read (when calling widget->move(x, y) frequently).
    So I was hoping there might be a better way to do graphics drawing so I can move things like text around without making it blurry, or what you'd call it...?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    One way can be to draw it once on a QImage and then draw that QImage in the paint event. You will have to refresh the QImage when the widget is resized.

  • @SGaist Why QImage and not QPixmap? Most of what I have read would suggest QPixmap, but you are the expert and, because I have a similar need, that is why I am asking

  • Qt Champions 2017

    QPixmap could also be used in this use case. But since he sounds like
    he plan to alter the image (manipulate) then QImage is suggested.


  • @mrjj I read the same item you provided the link to, but I did not get the idea that there was a plan to manipulate the image. If there was no manipulation of the image, just drawing on the display widget, then is one choice better that the other?

  • Qt Champions 2017

    Say you load an image and paint it over and over on the screen.
    Then QPixmap is said to be faster.
    However, if you load an image and manipulate its pixels ( like color correction) and draw it
    , QImage is more suited.

  • Thank you all for the help! And yes I needed to manipulate the image, so I went QImage :)
    It's working great so far!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.