PDA

View Full Version : How can I capture click events/signals of a QGraphicsSvgItem



theamrzaki
2nd April 2016, 23:55
I'm new to Qt. How can I capture click events/signals of a QGraphicsSvgItem inside a QGraphicsScene? I have the following code:


QGraphicsScene *scene = new QGraphicsScene(this);
QGraphicsSvgItem *svgItem = new QGraphicsSvgItem(":/SomeGraphic.svg");
svgItem->scale(0.1, 0.1);
svgItem->setPos(-200,-200);
scene->addItem(svgItem);
Is it possible to connect() the click() signal of svgItem to a slot?

d_stranz
3rd April 2016, 00:10
If it had such a signal, of course you could connect a slot to it. Unfortunately, there is no such signal. There are however, various mouse events which you could override in a class derived from QSvgGraphicsItem or which you could monitor by installing an event filter on the QSvgGraphicsItem itself.