Results 1 to 3 of 3

Thread: GraphicsPixmapItem follow a GraphicsPixmapItem

  1. #1
    Join Date
    May 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default GraphicsPixmapItem follow a GraphicsPixmapItem

    Hi there,

    I got 2 QGraphicsPixmapItem which both are separated classes (let say A and B). Object A is moving downwards in the scene. So when user clicks A, object B position should appear exactly at position A in the scene. However, I finding difficulties to allow B to follow A while Object A is constantly moving downwards. Any suggestion on how to do this? Thanks in advance.

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo
    Thanks
    1
    Thanked 26 Times in 26 Posts

    Default Re: GraphicsPixmapItem follow a GraphicsPixmapItem

    if you want B to jump in a place where A is, then just install event Filter on A and wait for mouse press event.

    If you want B to follow A afetr it's been clicked, the best would be to subclass GraphicsPixmapItem and modify itemChange method and mouse events. You can refer to the documentation where actually such thing is already done.

    QVariant QGraphicsItem::itemChange ( GraphicsItemChange change, const QVariant & value ) [virtual protected]

    You could have a custom signals and slots in both items and use them to connect the position change event.

  3. #3
    Join Date
    May 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: GraphicsPixmapItem follow a GraphicsPixmapItem

    Is there a real life example for this, I did read the docs but I'm still kinda blur on how to implement it. According to the docs, it just returned values.

Similar Threads

  1. Have translucent window follow mouse
    By mike_am_i in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2009, 10:18
  2. QGraphicsView to follow Item?
    By sven-kt in forum Qt Programming
    Replies: 5
    Last Post: 25th August 2009, 08:40
  3. How to follow a link in QWebKit?
    By piotr.dobrogost in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2009, 14:05
  4. How can I follow the mouse?
    By T.I.M in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2009, 08:42
  5. QPen brush doesn't follow transformations
    By Mercurio in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2007, 08:38

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.