Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drawing 70k objects in QGraphicsView - lag lag lag
Qt 6.11 is out! See what's new in the release blog

Drawing 70k objects in QGraphicsView - lag lag lag

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicsview
12 Posts 5 Posters 2.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    Hey

    I'm trying to draw quite..." few" lines/reacts inside QGraphicsView I've configured

        QOpenGLWidget *mGlWidget = new QOpenGLWidget();//QGLFormat(QGL::SampleBuffers));
        QSurfaceFormat format;
        format.setRenderableType(QSurfaceFormat::OpenGL);
        format.setVersion(4, 5);
        format.setSamples(8);
        mGlWidget->setFormat(format);
        setViewport(mGlWidget);
    

    And went on with painting but as far as I can tell its very "slow task". Is there anything else I can do or I have to go full standalone opengl solution? I have disabled paiting (void paint(){return;}) and it was pretty slow then too so mhmhm.... ? Perhaps I can't have a lot of items in QGraphicsView?

    TIA

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      It's probably less to do with whether it is a full openGL app, and more to do with the methods you're using to generate your scene. 70k objects? OK...nothing about rendering hardware or whether you are optimizing your scene generation?

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dariusz
        wrote on last edited by
        #3

        @Kent-Dorfman Hey, hardware wise 2990wx/2080super. As to generation, its just a loop for int x=0;x<100000;++x{}, I'm not even drawing the items. Just added to scene one time and then panning around in scene.

        Its my attempt at uv editor :- ) So object count can go well over 1 mil + and so on.

        A 1 Reply Last reply
        0
        • D Dariusz

          @Kent-Dorfman Hey, hardware wise 2990wx/2080super. As to generation, its just a loop for int x=0;x<100000;++x{}, I'm not even drawing the items. Just added to scene one time and then panning around in scene.

          Its my attempt at uv editor :- ) So object count can go well over 1 mil + and so on.

          A Offline
          A Offline
          Asperamanca
          wrote on last edited by Asperamanca
          #4

          @Dariusz
          GraphicsView is single threaded and not hardware accelerated. That said, it's relatively efficient code, so adding 70k items might take a bit of time, but it should be doable.

          I don't see any code what kind of items you are trying to add. The problem might lie there.

          The code you posted has little to do with GraphicsView per se, so the question is a bit unclear to me.

          1 Reply Last reply
          1
          • D Offline
            D Offline
            Dariusz
            wrote on last edited by
            #5

            @Asperamanca Hey, The code I added is being executed in graphicsView, it configures it to use openGL for drawing instead of CPU.

            The problem is not how long it takes to add items, but how well it performs once I added them. I'm using a base QGraphicsItem as my class and then extended that. In my extension I have disabled drawing so there is 0 drawing happening. Only items added to scene and qt run its own tests on them. As far as I can tell the drawing is not the issue, but just processing 70k items.

            I'm looking in to building openGL app for this as it does not look like QGraphicsView is optimized for it.

            Regards
            Dariusz

            A 1 Reply Last reply
            0
            • D Dariusz

              @Asperamanca Hey, The code I added is being executed in graphicsView, it configures it to use openGL for drawing instead of CPU.

              The problem is not how long it takes to add items, but how well it performs once I added them. I'm using a base QGraphicsItem as my class and then extended that. In my extension I have disabled drawing so there is 0 drawing happening. Only items added to scene and qt run its own tests on them. As far as I can tell the drawing is not the issue, but just processing 70k items.

              I'm looking in to building openGL app for this as it does not look like QGraphicsView is optimized for it.

              Regards
              Dariusz

              A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #6

              @Dariusz
              If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3

              D 1 Reply Last reply
              1
              • A Asperamanca

                @Dariusz
                If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3

                D Offline
                D Offline
                Dariusz
                wrote on last edited by
                #7

                @Asperamanca said in Drawing 70k objects in QGraphicsView - lag lag lag:

                @Dariusz
                If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3

                Well I'm just trying to understand where the bottleneck is... I did drawing, I had 1 fps. So I disabled all paint functions to see if that help, that did help, but I'm still having issues... so I take graphicsView is not for very large scenes then ?

                mrjjM 1 Reply Last reply
                0
                • D Dariusz

                  @Asperamanca said in Drawing 70k objects in QGraphicsView - lag lag lag:

                  @Dariusz
                  If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3

                  Well I'm just trying to understand where the bottleneck is... I did drawing, I had 1 fps. So I disabled all paint functions to see if that help, that did help, but I'm still having issues... so I take graphicsView is not for very large scenes then ?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Dariusz
                  Hi
                  I if take the 40000 sample
                  https://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
                  and double the items so it creates 80.000, its still not lagging.

                  D 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Dariusz
                    Hi
                    I if take the 40000 sample
                    https://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
                    and double the items so it creates 80.000, its still not lagging.

                    D Offline
                    D Offline
                    Dariusz
                    wrote on last edited by
                    #9

                    @mrjj Hey hmmm, I just tried that example, paning/moving seems to somewhat work, but selecting/moving and bigger action begin to lag mhmhmhmm. Darn I was really hopping to do it in qt.

                    mrjjM 1 Reply Last reply
                    0
                    • fcarneyF Offline
                      fcarneyF Offline
                      fcarney
                      wrote on last edited by fcarney
                      #10

                      Why would QGraphicsView go out of its way to slow down the OpenGL implementation? Are you using modern OpengGL techniques or the old interface which is slow and outdated? Are you using shaders? If no, then it probably isn't modern OpenGL. Without showing your code you are not helping yourself sort this out.

                      https://learnopengl.com/Offline-book
                      This book helped me. It is based on post 3.3 opengl if I remember right.

                      Edit: Also, yes, it is possible Qt is not what you need, but I don't think Qt is inherently slow at OpenGL.

                      C++ is a perfectly valid school of magic.

                      1 Reply Last reply
                      1
                      • fcarneyF Offline
                        fcarneyF Offline
                        fcarney
                        wrote on last edited by
                        #11

                        @Dariusz your expression "mhmhmhmm" made me think of this all day:
                        https://youtu.be/Vppbdf-qtGU?list=RDEMMMZUoWkd7ELYUXXPeLGHyg&t=40

                        C++ is a perfectly valid school of magic.

                        1 Reply Last reply
                        1
                        • D Dariusz

                          @mrjj Hey hmmm, I just tried that example, paning/moving seems to somewhat work, but selecting/moving and bigger action begin to lag mhmhmhmm. Darn I was really hopping to do it in qt.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Dariusz
                          Ok so you could get the 40K sample to lag also ?

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved