Results 1 to 2 of 2

Thread: QGraphicsSvgItem - how to make clickable?

  1. #1
    Join Date
    Mar 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsSvgItem - how to make clickable?

    How can I make a QGraphicsSvgItem that is added to a scene clickable? I am adding it as follows:

    Qt Code:
    1. svgItem = new QGraphicsSvgItem(":/MySVGImage.svg");
    2. svgItem->scale(0.1, 0.1);
    3. scene->addItem(svgItem);
    4. ...
    5. ui->graphicsView->setScene(scene);
    To copy to clipboard, switch view to plain text mode 

    How can I now detect that this particular svgItem has been clicked?

    Any help really appreciated. Thanks.
    Last edited by scott.deagan; 8th March 2012 at 12:01.

  2. #2
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Re: QGraphicsSvgItem - how to make clickable?

    How do you want to handle the clicks?

    If it's just basic stuff like selecting or moving it around, you can just set flags (e.g., "setFlag(ItemIsSelectable,true);"). If it's more complicated, you should subclass QGraphicsItem or QGraphicsSvgItem and implement your own functionality. You'd need to reimplement QGraphicsItem::mousePressEvent.

    I recommend looking at this video: http://www.youtube.com/watch?v=hgDd2QspuDg
    Last edited by wayfaerer; 8th March 2012 at 17:12.

Similar Threads

  1. Clickable URL in QMessageBox?
    By martinb0820 in forum Qt Programming
    Replies: 5
    Last Post: 23rd March 2012, 04:45
  2. Replies: 1
    Last Post: 29th December 2010, 14:53
  3. How to make a custom qwidget clickable ?
    By ada10 in forum Newbie
    Replies: 2
    Last Post: 1st September 2010, 12:55
  4. QLabel clickable
    By bnilsson in forum Newbie
    Replies: 3
    Last Post: 29th July 2009, 08:50
  5. Clickable text?
    By hkvm in forum Qt Programming
    Replies: 2
    Last Post: 27th September 2008, 21:49

Tags for this Thread

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.