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 repaint loop
Forum Updated to NodeBB v4.3 + New Features

QGraphicsScene repaint loop

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • S Offline
    S Offline
    stvokr
    wrote on last edited by
    #1

    Hi,

    I am using Qt 4.8.1 and Qt 5.2.1 on Windows 7.

    My current project is like a visual editor where you can set up several nodes and connect them with edges. It is like a visual representation of a tree structure. Both, nodes and edges, are derived from QGraphicsItem. Their user defined appearance is implemented in the paint() function. All items are placed in my GraphicsScene class, derived from QGraphicsScene.

    Now my problem is that, when I have about 100 or more items in the scene (most of the edge items intersect each other), the paint event of all items (!) is triggered in an endless loop (CPU load 100%), without any user interaction. Only when I move most of the items out of the viewport so that only a few items are visible the endless repaint stops.

    This problem occurs on both Qt versions.

    Does anyone have an idea?

    regards
    Oliver

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giordi
      wrote on last edited by
      #2

      Are you sure you are not forcing manually repaint() of items somewhere?
      That might lead to some hard to find loops.
      When I did back in the days the same thing I did not end up having this kind of probem. Even tho it was pyqt4

      Coding is powaaaaa

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stvokr
        wrote on last edited by
        #3

        Not directly, but I found something which could be the reason:

        My edge items vary in size and hence boundingRect size. So I used the function prepareGeometryChange() to tell the item, that the boundingRect has changed. But unfortunately it was called within the paint() function, and so the loop was perfect, because prepareGeometryChange() is able to perform an update to the scene (if necessary) and so trigger the repaint itself.

        Thanks for the advice
        Oliver

        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