Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Triggering drawForeground and drawBackground
Qt 6.12 LTS is out! See what's new in the release blog

Triggering drawForeground and drawBackground

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 985 Views
  • 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.
  • I Offline
    I Offline
    Iyad Ahmed
    wrote on last edited by
    #1

    Re: [SOLVED]Qt 5.2.1 GraphicsView::drawBackground and drawForeground are not called after GraphicsView::Update()

    I have been looking for a way to trigger drawForground after updating properties on mouse move, first I was using update() method of graphics scene, it worked prefectly, but I didn't want to trigger and entire update every time the mouse moved in my case (a selection box)

    anyhow, I found the solution in documentation and it worked perfectly
    https://doc.qt.io/qt-6/qgraphicsscene.html#invalidate

    now I call this everytime I want to trigger only the forground layer redraw
    self.invalidate(self.sceneRect(), QGraphicsScene.ForegroundLayer)

    best regrads,
    Iyad

    1 Reply Last reply
    1
    • I Offline
      I Offline
      Iyad Ahmed
      wrote on last edited by
      #2

      There's a catch though, graphics_scene.update() makes the forground drawn even outside the boundaries of the scene, which is what I desired in my case, invalidate with scene rect doesn't, because it is limited to the rect we pass to it

      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
      • Unsolved