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. Painting GraphicsItems directly
QtWS25 Last Chance

Painting GraphicsItems directly

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 526 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    I am implementing a kind of scroll area that can be used within a GraphicsScene. It consists of a canvas, which contains all the items to show, and a viewport, which shows a part (or all) of the canvas, and handles zooming as well. In short, canvas is to viewport as QGraphicsScene is to QGraphicsView. Just that everything is completely inside a GraphicsScene.

    Of course, I could attach multiple viewports to a single canvas. Therefore, I cannot simply reparent the canvas when assigning it to a viewport.

    Now how do I paint the part of the canvas that should be visible inside the viewport?

    My idea was to implement the viewport's paint method, and directly paint the canvas by calling it's paint method (after setting all the necessary transformations on the painter).
    However, this method only paints the canvas itself, but not the items contained within. Because the paint() method does not itself recursively call the paint methods of the children.

    QUESTION:
    How do I paint a whole tree (i.e. an item including all it's children) to a QPainter?

    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