So i created a few MyItem instances and addItem()ed then to my custom QGraphicsView. This works perfectly, and the widgets show up just fine.
However, the scene()->itemAt(...) functions returns always zero, when given the coordinates obtained from a QMouseEvent.
class MyItem: public QGraphicsProxyWidget
{
MyItem() {
setWidget(new SomeWidget());
}
//...
};
class MyItem: public QGraphicsProxyWidget
{
MyItem() {
setWidget(new SomeWidget());
}
//...
};
To copy to clipboard, switch view to plain text mode
void MyQGraphicsView
::mousePressEvent( QMouseEvent *event
) {
itm = scene()->itemAt(event->pos(), transform()); //nope
}
void MyQGraphicsView::mousePressEvent( QMouseEvent *event )
{
QGraphicsItem* itm = scene()->itemAt(event->pos()); //nope
itm = scene()->itemAt(event->pos(), transform()); //nope
}
To copy to clipboard, switch view to plain text mode
Now, i am still struggling with understanding all the transformation stuff :/, but to my understanding, nothing of that sort should be necessary here? Unfortunately, this seems to be a rarely used function, and i cant seem to find any proper examples.
Do i have to apply some magic to the coordinates before passing them to the function? What else could be wrong?
Bookmarks