I have lines in Qt graphics UI. I want to highlight the line on mouse hover
-
0
I have created the QGraphicsView in the Qt dialog. Added some lines in the QGraphicsView. I want to highlight the line on mouse hover. here not getting Object of line on mouse hover to highlight.
bool QtdlUI::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::MouseMove)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF Inpos = mouseEvent->scenePosition();
QGraphicsItem* Graphicsit = Gscene->itemAt(Inpos, ui.graphicsView->transform());
}
}
I tried above code but getting QGraphicsItem null. -
Hi and welcome to devnet,
Did you check the actual position value you're using with regard to the item position ?
What is QtdlUI ? -
0
I have created the QGraphicsView in the Qt dialog. Added some lines in the QGraphicsView. I want to highlight the line on mouse hover. here not getting Object of line on mouse hover to highlight.
bool QtdlUI::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::MouseMove)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF Inpos = mouseEvent->scenePosition();
QGraphicsItem* Graphicsit = Gscene->itemAt(Inpos, ui.graphicsView->transform());
}
}
I tried above code but getting QGraphicsItem null.@Ajit-Patil said in I have lines in Qt graphics UI. I want to highlight the line on mouse hover:
I want to highlight the line on mouse hover
One possible way to do so: Subclass your item and re-implement these two functions in your
QGraphicsItem
void hoverEnterEvent(QGraphicsSceneHoverEvent * event); void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);