PDA

View Full Version : mouseDoubleClickEvent in QGraphicsItemGroup



dima
9th March 2009, 07:01
Hi,
1. In my project I subclassing QGraphicsItemGroup to CQCustomGraphicsItemGroup

CQCustomGraphicsItemGroup::CQCustomGraphicsItemGro up(QObject* observer, QGraphicsItemGroup *parent)
: QGraphicsItemGroup(parent),
m_observer(observer)
{
setHandlesChildEvents(true);
setAcceptHoverEvents(true);
setCacheMode(DeviceCoordinateCache);
}

2. I need to notify observer from constructor on every mousePressEvent and mouseDoubleClickEvent !!!

3. I use custom event class that inherit from QEvent and QApplication::sendEvent function to notify observer.

4. mousePressEvent code
void CQCustomGraphicsItemGroup::mousePressEvent(QGraphi csSceneMouseEvent* event)
{
// user defined event inherit from QEvent
CQGraphicsCustomEvent* customEvent =
new CQGraphicsCustomEvent(QEvent::User + 1);
QApplication::sendEvent(m_observer, customEvent);
}

5. mouseDoubleClickEvent code
void CQCustomGraphicsItemGroup::mouseDoubleClickEvent(Q GraphicsSceneMouseEvent* event)
{
// user defined event inherit from QEvent
CQGraphicsCustomEvent* customEvent =
new CQGraphicsCustomEvent(QEvent::User + 2);
QApplication::sendEvent(m_observer, customEvent);
}



6. Problem!!!
mouseDoubleClickEvent not activated on each my double click . Sometimes i need to make double doubleClick on item to activate event ,and Only if I close in comments function mousePressEvent it work correctly!!!????