Results 1 to 3 of 3

Thread: How can I add the graphics rect items to a certain place

  1. #1
    Join Date
    Sep 2008
    Posts
    93
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default How can I add the graphics rect items to a certain place

    Hello,

    I use the QGraphicsScene, QGraphicsView and QGraphicsRectItem to display 15 images by 5x3.
    But I can not add the rect item in certain place,
    I use the function void QGraphicsScene::addItem ( QGraphicsItem * item )from the class QGraphicsScene. only the first image was displayed.

    I also used the function void QGraphicsRectItem::setRect ( qreal x, qreal y, qreal width, qreal height ). But I can only set x=0, and y=0.

    Please give some help.

  2. #2
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I add the graphics rect items to a certain place

    From Assistant
    void QGraphicsItem::setPos ( const QPointF & pos )

    Sets the position of the item to pos, which is in parent coordinates. For items with no parent, pos is in scene coordinates.

    The position of the item describes its origin (local coordinate (0, 0)) in parent coordinates.

    See also pos(), scenePos(), and The Graphics View Coordinate System.

    void QGraphicsItem::setPos ( qreal x, qreal y )

    This is an overloaded function.

    This convenience function is equivalent to calling setPos(QPointF(x, y)).

  3. The following user says thank you to Grimlock for this useful post:

    learning_qt (8th September 2009)

  4. #3
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I add the graphics rect items to a certain place

    Be aware of relatives coordinates, from your scene, your group or your item, since the geometry of an item is relative to its parent item.

    Another point to check if the zValue.

    S.Cascio

Similar Threads

  1. Graphics View: Drawing Items that don't scale
    By Disperato in forum Qt Programming
    Replies: 5
    Last Post: 6th July 2009, 17:16
  2. Replies: 7
    Last Post: 26th June 2009, 19:33
  3. Replies: 6
    Last Post: 8th June 2009, 21:44
  4. Replies: 5
    Last Post: 17th February 2009, 04:35
  5. Want custom menu items, like graphics, but how?
    By rm in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2008, 20:52

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.