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. QGraphicsScene/QGraphicsView performance
Qt 6.11 is out! See what's new in the release blog

QGraphicsScene/QGraphicsView performance

Scheduled Pinned Locked Moved General and Desktop
15 Posts 6 Posters 8.7k Views 1 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.
  • O Offline
    O Offline
    onurozcelik
    wrote on last edited by
    #6

    [quote author="zgulser" date="1297760455"]Finally, what's the renderer?
    [/quote]

    QSvgRenderer instance pointer.

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onurozcelik
      wrote on last edited by
      #7

      [quote author="Jorj" date="1297696052"]you are emitting signals during your paint method, if these are connected to the (im assuming) game logic, and trigger a redraw, you will get an infinite ish loop[/quote]

      I commented emit stuff but CPU usage did not change.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zgulser
        wrote on last edited by
        #8

        Ok.

        I think you should do all other controlling stuff outside the paint method( I bet you know signal-slot issue) and just perform renderer->render(painter,boundingRect()); in it.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MarekR22
          wrote on last edited by
          #9

          As I can see now you mess up everything with everything.

          • paint method should do only painting nothing else (performance reasons)
          • sizeHint is hardcoded I doubt you reale need this
          • boundingRect is wrong for sure.
          • you messing around with properties when it is not needed (this is needed if code supposed to manipulate objects with unknown api/structure).

          Maybe explain what this should show!

          [EDIT: fixed list - use "*" instead of "-" as "bullets", Volker]

          1 Reply Last reply
          0
          • O Offline
            O Offline
            onurozcelik
            wrote on last edited by
            #10

            MarekR22

            How should I implement boundingRect()?
            Sample code please.

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zgulser
              wrote on last edited by
              #11

              Although it won't solve your problem totally, it should be something like;

              @

              void Item::setBoundingRect(const QRect& pBoundingRect)
              {
              mBoundingRect = pBoundingRect;
              }

              const QRect& Item::getBoundingRect()
              {
              return mBoundingRect;
              }

              const QRect& Item::boundingRect()
              {
              return getBoundingRect();
              }
              @

              1 Reply Last reply
              0
              • I Offline
                I Offline
                ivan
                wrote on last edited by
                #12

                You could also cache the svg render output to a pixmap.

                Ivan Čukić | ivan.cukic(at)kde.org | KDE e.V.
                Qt Ambassador (from the old Nokia days)

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MarekR22
                  wrote on last edited by
                  #13

                  [quote author="onurozcelik" date="1297780179"]MarekR22

                  How should I implement boundingRect()?
                  Sample code please.[/quote]
                  The joke is that you don't have to. QGraphicsWidget returns boundingRect which in most cases should be ok.
                  But like I said describe what you are trying to achieve then we will show you how code should look like.
                  Note there is a class "QGraphicsSvgItem":http://doc.trolltech.com/latest/qgraphicssvgitem.html. Maybe this is enough for you.

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    onurozcelik
                    wrote on last edited by
                    #14

                    implementing boundingRect correctly solved the infinite repaint loop problem.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #15

                      [quote author="zgulser" date="1297781851"]
                      Although it won't solve your problem totally, it should be something like;

                      @

                      void Item::setBoundingRect(const QRect& pBoundingRect)
                      {
                      mBoundingRect = pBoundingRect;
                      }

                      const QRect& Item::getBoundingRect()
                      {
                      return mBoundingRect;
                      }

                      const QRect& Item::boundingRect()
                      {
                      return getBoundingRect();
                      }
                      @[/quote]

                      For performance critical code, you should just inline the stuff above.

                      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