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. QGraphicsItem's child items always on top
Forum Updated to NodeBB v4.3 + New Features

QGraphicsItem's child items always on top

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.9k 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 all,

    I have a scene with some QGraphicsItems (let's call them "groups"), which contains some other graphics items as children.
    The groups have all a background color or image and the same z-value (= 1), but they are painted in creation order. You can see which is painted last, when the groups overlap.
    Now, the child items within these groups have a higher z-value (= 10) than the groups themselves. But the child items are also overlapped by other groups.
    It seems to me the correct way how this is working, but for my case I want the child items to stay on top of all groups. It this possible?

    regards
    Oliver

    1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by m.sue
      #2

      Hi,
      the docu says "The Z value decides the stacking order of sibling (neighboring) items". Siblings are items that have the same parent (I would assume), in your case: the groups.

      So I would say that one group that covers another group always also covers the children of the other group. The z=10 of the children just affects the children within the group (they are siblings). But you could as well not set it as the children are on top of their parents, by default, anyway.
      -Michael.

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

        You can use the following flags to influence this behavior: QGraphicsItem::ItemStacksBehindParent and QGraphicsItem::ItemNegativeZStacksBehindParent

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved