I have a scene with a mosaic of QGraphicItemGroup's and I'm trying to make it when the user clicks on one of the QGraphicsItemGroup's it will bring it to the front. I have tried a few modifications of the following code snippit with no success.
{
if (o == ui.view->viewport())
{
QPointF point
= ui.
view->mapToScene
(ui.
view->mapFromGlobal
(QCursor::pos()));
if (tmp != 0)
tmp->setZValue(1000.0);
}
}
bool form::eventFilter(QObject *o, QEvent *e)
{
if (o == ui.view->viewport())
{
QPointF point = ui.view->mapToScene(ui.view->mapFromGlobal(QCursor::pos()));
QGraphicsItem *tmp = ui.view->itemAt(point.x(), point.y());
if (tmp != 0)
tmp->setZValue(1000.0);
}
}
To copy to clipboard, switch view to plain text mode
Am I not supposed to be using the QGraphicsView's eventFilter for this?
When I use the itemAt function it returns a QGraphicsItem. Does it need to be a QGraphicsItemGroup?
Any tips would be great...
Note: I posted a similar question a while back, but I don't see this as the same question. In my previous post I was able to add an object to a new QGraphicsItemGroup prior to setting the ZValue. In this case, I already have the group's created, and I just want to display a certain one above others.
Thanks!
Bookmarks