Fastest way to paint a lot of squares

  • Hello,
    in my current project I have to draw a lot of squares (amount can vary between 100 and 2^27 (~10^8), which build a grid. Each square has a specific color (7 different colors) which is updated really fast and often (ca. 500Hz).
    Now I am searching for the most performant way to realise this.
    In an older version I used QGraphicsView and QGraphicsScene with a subclass of QGraphicsItem for each square, but the result was too slow and it looked not very smoothy.
    I know that the human can't really recognize 500 frames per second, but the update rate is that high and I simply want to display a smoothy picture which shows any greater change.
    What is currently the best Widget I have to choose? An OpenGL-Widget? With QGraphicsView or not? A lot of independent Widgets? I read of a new QQuickWindow. Is it possible to use this widget for my purpose?

    If you have any further questions or I wrote anything unintelligible, don't hesitate to ask.

    Thank you!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    If you want fast graphics then go with OpenGL.

    However realise that beside the fact that the human eye/brain can't handle 500Hz refresh rate, there's currently no consumer device that does this either. Even current high-end graphics card don't provide such a refresh rate and no screens supports that.

  • Thanks for your answer and your advice. I will try out OpenGL.

    I know that 500Hz are too high for human senses, but I just wanted to mention the actual refresh rate of the state. You can't either see the single squares if there are 2^27 of them. I only want to see the approximate movement of square groups. So you don't actually need 500Hz, 50-60Hz would be more than enough (my monitor actually can''t display more FPS). But with my current implementation I have a refresh rate of ~2-3Hz. But yeah, you are right. I think I simply have to skip some states and draw only every tenth color of a square. That might be the weakness in my current version.

  • Lifetime Qt Champion

    It's a bit like video games: only draw precisely what a user can see closely and then start reducing the quality for what is behind until you can even drop what's far.

Log in to reply

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