[Interest] Problem with setEnabled on QGraphicsItem
Jean-Michaël Celerier
jeanmichael.celerier at gmail.com
Thu Apr 9 12:41:26 CEST 2015
Hello,
I am having some trouble with QGraphicsItem and mouse event forwarding.
The doc (5.4) states, about QGraphicsItem::setEnabled() :
Mouse events are discarded; they are not propagated unless the item is also
invisible, or if it does not accept mouse events (see
acceptedMouseButtons()).
However, I observe the following behaviour :
I have the two following methods :
void DeckView::enable()
{
for(QGraphicsItem* item : childItems())
{
// item->setEnabled(true);
item->setAcceptedMouseButtons(Qt::AllButtons);
item->setFlag(ItemStacksBehindParent, false);
}
delete m_overlay;
}
void DeckView::disable()
{
for(QGraphicsItem* item : childItems())
{
// item->setEnabled(false);
item->setAcceptedMouseButtons(0);
item->setFlag(ItemStacksBehindParent, true);
}
m_overlay = new DeckOverlay{this};
}
In this case, the event properly gets forwarded to the item under DeckView.
However, I have a child item which contains a QGraphicsProxyWidget, and the
widget still gets and reacts to the mouse events.
If I uncomment the "item->setEnabled(true);" lines, the
QGraphicsProxyWidget stops reacting to the mouse event, however, the mouse
event don't get passed to the item under anymore !
If I do "item->setInvisible(true);" the mouse event gets passed to the item
under again, but I want them to be visible... hence the
setAcceptedMouseButtons, but it does not change anything when disabled.
Any idea?
Best,
Jean-Michaël Celerier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150409/deacc0a7/attachment.html>
More information about the Interest
mailing list