lolcott
9th August 2017, 22:37
Hi all, real newbie here. I'm working with a custom qGraphicsItem. When i hover over it i display a contact menu. Works great
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()));
}
}
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:
myMenu = new QMenu();
connect(myMenu, SIGNAL(QWidget::leaveEvent(QEvent* event)), this, SLOT(popupLeave()));
but i get QObject::connect: No such signal QMenu::QWidget::leaveEvent(QEvent* event)
Any pointers??
Thanks in advance
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()));
}
}
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:
myMenu = new QMenu();
connect(myMenu, SIGNAL(QWidget::leaveEvent(QEvent* event)), this, SLOT(popupLeave()));
but i get QObject::connect: No such signal QMenu::QWidget::leaveEvent(QEvent* event)
Any pointers??
Thanks in advance