[Qt-interest] Connecting context menu to slot in QGraphicsItem
Cole, Derek
dcole at integrity-apps.com
Thu Apr 7 23:03:17 CEST 2011
Hello,
I have created a QGraphicsItem subclass, and I am trying to add a right-click popup context menu to it.
I have the following:
void ImagePixmapItem::right_clicked(){
qDebug("Got here!");
}
void ImagePixmapItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
QMenu *menu = new QMenu();
QAction *removeAction = menu->addAction("Remove");
QAction *markAction = menu->addAction("Mark");
QAction *selectedAction = menu->exec(event->screenPos());
connect(menu, SIGNAL(triggered(QAction *)),this, SLOT(right_clicked()));
}
This compiles, and does not throw any errors at runtime, but I never get the line "Got Here!" printed. What am I doing incorrectly to fire off an action based on a selection from a context menu?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110407/da448322/attachment.html
More information about the Qt-interest-old
mailing list