scascio
28th September 2009, 11:44
Dear Qt workers,
Working with QGraphicsView, I managed an overlayed child QWidget attached to the mouse.
Since I need to control my view from the mouse, I catch events in the widget then I can call slots by emitting signals.
But my problem is to transmit mouse events to QGraphicsItem, for instance to take benefit of default selecting and moving, or change item state by double clicking.
Mouse event cannot reach items, event if I write :
void QCursorView::mouseDoubleClickEvent(QMouseEvent * event) {
QWidget::mouseDoubleClickEvent(event);
QMouseEvent translatedEvent(event->type(),
mapTo(parentWidget(), event->pos()),
event->button(),
event->buttons(),
event->modifiers());
qApp->sendEvent(parentWidget(), &translatedEvent);
}
Neither the view receive the event.
What is the way to send events properly?
Is there any restriction according to widget hierarchy and event calling stack?
Thanks by advance
PS: I cannot use Qt::WA_TransparentForMouseEvents since I need to do some computation in the child widget in response of some events.
since
S.Cascio
Working with QGraphicsView, I managed an overlayed child QWidget attached to the mouse.
Since I need to control my view from the mouse, I catch events in the widget then I can call slots by emitting signals.
But my problem is to transmit mouse events to QGraphicsItem, for instance to take benefit of default selecting and moving, or change item state by double clicking.
Mouse event cannot reach items, event if I write :
void QCursorView::mouseDoubleClickEvent(QMouseEvent * event) {
QWidget::mouseDoubleClickEvent(event);
QMouseEvent translatedEvent(event->type(),
mapTo(parentWidget(), event->pos()),
event->button(),
event->buttons(),
event->modifiers());
qApp->sendEvent(parentWidget(), &translatedEvent);
}
Neither the view receive the event.
What is the way to send events properly?
Is there any restriction according to widget hierarchy and event calling stack?
Thanks by advance
PS: I cannot use Qt::WA_TransparentForMouseEvents since I need to do some computation in the child widget in response of some events.
since
S.Cascio