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. What is the difference between update and invalidate for QGraphicsScene?
Forum Updated to NodeBB v4.3 + New Features

What is the difference between update and invalidate for QGraphicsScene?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.8k 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
    opengpu
    wrote on last edited by
    #1

    what is the difference between update and invalidate for QGraphicsScene?
    and when to set the rect for them?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      Unless you directly paint into the scene (drawBackground, drawForeground) you'll rarely ever need to invalidate or update a specific rect. When you make changes to QGraphicsItems, and their boundingRects are correct, they take care of the required updates.

      In some cases you might want to repaint the entire scene, which can be done using update().
      Invalidate gives you more control about which layer of the scene you want to invalidate. A scene has a background layer (which you draw using drawBackground), a foreground layer (which you draw using drawForeground) and in between the item layer. As noted in the docs, calling invalidate on any layer but the background layer is equivalent to calling update.

      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