Disable changing of shape of cursor when it inside of QTextEdit
-
Oh, May i realize it? I want to my GraphicsView get events of my GraphicsItem. I want to my GraphicsView filters events of my GraphicsItem .
@Kaznachei
Hi
The syntax is
monitoredObj->installEventFilter(filterObj);monitoredObj = GraphicsItem
filterObj = GraphicsView
and this should have the
:eventFilter(QObject* obj, QEvent *event)
function. -
In GraphicsView
RectItem* item = new RectItem;
item->setObjectName("I");
item->setPos(event->pos() - QPoint(item->rect().width()/2, item->rect().height()/2));
item->installEventFilter(this);and
bool eventFilter(QObject *obj, QEvent *event)
{
if (obj->objectName() == "I")
qDebug() << "ok"
return QGraphicsView::eventFilter(obj, event);
}qDebug() doesn`t write.
-
In GraphicsView
RectItem* item = new RectItem;
item->setObjectName("I");
item->setPos(event->pos() - QPoint(item->rect().width()/2, item->rect().height()/2));
item->installEventFilter(this);and
bool eventFilter(QObject *obj, QEvent *event)
{
if (obj->objectName() == "I")
qDebug() << "ok"
return QGraphicsView::eventFilter(obj, event);
}qDebug() doesn`t write.
@Kaznachei
Hi
try withbool eventFilter(QObject *obj, QEvent *event) { qDebug() << obj->objectName(); if (obj->objectName() == "I") qDebug() << "ok" return QGraphicsView::eventFilter(obj, event); }
and see what is going on
-
qDebug write only this
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""
""@Kaznachei
Hmm. odd.
Try
qDebug() << obj->metaObject()->className()
and see what type it is.Else use the debugger to see what obj is.
-
Hi
Maybe eventFilters do not work on QGraphicsItems
I have never tested it but since they are not qobjects, i think its a no go. -
Yes. I read that QGraphicsObject has eventFilter, but not QGraphicsItem. Thank you a lot for ur helping.
@Kaznachei
yes QGraphicsObject also inherits from QObject so that makes good sense it can use event filters too.
You are most welcome. -
Hi,
You might be interested by the installSceneEventFilter method