Hi all, real newbie here. I'm working with a custom qGraphicsItem. When i hover over it i display a contact menu. Works great
{
myMenu->clear();
setCursor(Qt::ClosedHandCursor);
sandbox *myScene = dynamic_cast<sandbox *>(scene());
if(myScene->mode()==sandbox::ModeMakeConnection)
{
QAction action1
("EchoConnect",
this);
myMenu->addAction(&action1);
myMenu
->exec
(QPoint(event
->screenPos
().
x(),event
->screenPos
().
y()));
}
}
void pieces::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
myMenu->clear();
setCursor(Qt::ClosedHandCursor);
sandbox *myScene = dynamic_cast<sandbox *>(scene());
if(myScene->mode()==sandbox::ModeMakeConnection)
{
QAction action1("EchoConnect", this);
myMenu->addAction(&action1);
myMenu->exec(QPoint(event->screenPos().x(),event->screenPos().y()));
}
}
To copy to clipboard, switch view to plain text mode
however i'm trying to close it when i hover off. Running into issue here. I can't call the QGraphicsItem's hover leave because my focus is on the menu. so i'm trying to connect to qMenu's leaveEvent and failing. Here's what i'm trying:
connect(myMenu,
SIGNAL(QWidget::leaveEvent(QEvent* event
)),
this,
SLOT(popupLeave
()));
myMenu = new QMenu();
connect(myMenu, SIGNAL(QWidget::leaveEvent(QEvent* event)), this, SLOT(popupLeave()));
To copy to clipboard, switch view to plain text mode
but i get QObject::connect: No such signal QMenu::QWidget::leaveEvent(QEvent* event)
Any pointers??
Thanks in advance
Bookmarks