Results 1 to 3 of 3

Thread: QGraphicsItems on top of each other?

  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsItems on top of each other?

    Hello. I'm writing a game and now I wonder:
    If a QGraphicsItem moves so that it ends up inside of a larger QGraphicsItem, is there any easy way of making the smaller one end up on top of the larger one?

    It would be very nice with a "layer order" or something. I will have 3 different items. One huge covering the entire screen (map), and some minor ontop of this(castles), and then some very small that are always displayed on top of everything else (fighters).

    Or do I have to do this with the parent/child stuff? That will be hard since I don't think it will be efficient to put all child/parent connections!!! There will likely be more than 10 000 child/parent relations!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsItems on top of each other?

    Set the "z" coordinate (QGraphicsItem::setZValue()) of the smaller item to be lower (or higher, I don't remember) than the "z" coordinate of the bigger item.

  3. #3
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItems on top of each other?

    Thanks!
    You really knows this stuff and the Qt guys have really thought of these things.

Similar Threads

  1. Implementing scale-invariant QGraphicsItems
    By spud in forum Qt Programming
    Replies: 12
    Last Post: 13th January 2012, 05:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.