Results 1 to 2 of 2

Thread: QGraphicsScene - tagging picuters

  1. #1
    Join Date
    Jul 2009
    Posts
    9
    Thanks
    1

    Default QGraphicsScene - tagging picuters

    Hello!

    I've got QGraphicsScene, as a background I use a pixmap (I used texture brush). Now I want to make some invisibe rectangular shapes on graphics scene which will be something like tags on the picture. When I move a mouse over a specified field on a picture (where the invisible rectangulars are) I want the rectangular and small cloud with text to appear. Like I wrote before it should work like tags on the picture. I've got some ideas how to do it, but I need your help. The biggest issue for me is a relation of text from the cloud and shape itself.

    Thanks for your time

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

    Default Re: QGraphicsScene - tagging picuters

    Why not derived your own QGraphicsItem?

    Define the shape of your active area by implementing the pure virtual method QGraphicsItem::boundingRect(), then more precisely with QGraphicsItem::shape().
    Then overload mouses event to set a flag member. QGraphicsItem::hoverEnterEvent and QGraphicsItem::hoverLeaveEvent may fit your needs.
    Finally, overload the QGraphicsItem::paint method (pure virtual too), to paint your cloud conditionnally to your member flag.

    Since the paint do only drawing, item features like selecting, dragging and hovering are still alavailble, even if the paint does nothing.

    S.Cascio

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. [QGraphicsView] Auto adjusting QGraphicsScene
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2009, 22:31
  3. Replies: 0
    Last Post: 5th March 2009, 06:54
  4. QPixmap display on QGraphicsScene
    By febil in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2009, 09:27
  5. in QGraphicsScene matrix of other QGraphicsScene
    By Noxxik in forum Qt Programming
    Replies: 5
    Last Post: 15th February 2009, 17:27

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.