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. Clipping & Viewports with QGraphicsView and QGraphicsScene
Forum Updated to NodeBB v4.3 + New Features

Clipping & Viewports with QGraphicsView and QGraphicsScene

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

    I'm working on a project right now that has extensive use of the QGraphicsView framework. I have this scene where I only want to display/draw items that are within the bounds (0, 0, 5000, 100) ((left, top, right, bottom)). I currently have an item that has a negative x position, but half of it is still within the bounds.

    My View is drawing the whole item when I only want to draw half of it. I want it clipped along the Y-origin. How do I do this?

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

      One easy way would be to create an invisible parent item for the items you want to clip. Give it the clip rect you want as boundingRect, and add the "ItemClipsChildrenToShape" flag.

      You can also use the flag ItemClipsToShape to restrict a single item to it's own shape.

      Finally, you can always clip manually by setting clip rects or regions on the painter in the respective paint() methods.

      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