Results 1 to 2 of 2

Thread: setZValue with groupitem doesn't seem to work

  1. #1
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default setZValue with groupitem doesn't seem to work

    I am trying to create a QGraphicsEllipseItem that is shown stacked on top of all other elements (because it is the newest one created). I don't understand why the following is not working by using the "setZValue" function. Is there a way to just make it go on top of all other scene elements because it's the newest? Thanks!

    Qt Code:
    1. group = new QGraphicsItemGroup();
    2.  
    3. tmp = scene->addEllipse(QRectF(x, y, 10, 10));
    4. tmp->setPen(pen);
    5. tmp->setBrush(brush);
    6. tmp->setZValue(1000.0);
    7. group->addToGroup(tmp);
    To copy to clipboard, switch view to plain text mode 

    I noticed that when I comment out the last line "group->addToGroup(tmp);" the setZValue seems to work. Any input would be super.
    Last edited by forrestfsu; 24th October 2006 at 21:31.

  2. #2
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: setZValue with groupitem doesn't seem to work

    I can't believe this is all I had to do to solve the issue! I can't even explain how much time I wasted looking at this, but here's the correct way to do it:

    Qt Code:
    1. group = new QGraphicsItemGroup();
    2. tmp = scene->addEllipse(QRectF(x, y, 10, 10));
    3. tmp->setPen(pen);
    4. tmp->setBrush(brush);
    5. group->addToGroup(tmp);
    6. group->setZValue(1000.0);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qt 4.2: QListWidget changes size of its items
    By KingFish in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 11:06
  2. QGraphicsItem problem - how to save items info ??
    By aamer4yu in forum Qt Programming
    Replies: 3
    Last Post: 17th October 2006, 12:17
  3. Replies: 3
    Last Post: 27th July 2006, 12:48
  4. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20
  5. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04

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
  •  
Qt is a trademark of The Qt Company.