PDA

View Full Version : QGraphicsItem mouse out of focus



bunjee
21st June 2009, 22:31
Hey guys,

I want to emulate a "real button click" on a QGraphicsItem:
The click is triggered when mouse release + cursor inside.

Anyone could fill my blank here:


void qwListGraphicsItem::mouseReleaseEvent(QGraphicsSce neMouseEvent * event)
{
Q_D(qwListGraphicsItem);

if (/* cursor is not over the QGraphicsItem */ == true) return;

// Do something...
}


Thanks.

wysota
21st June 2009, 22:41
What is a "real button click"? You will only get the release event if the cursor hits the shape() of the item. Is that "inside" enough?

aamer4yu
22nd June 2009, 05:25
If you want your item to be shown as pressed,,, try to set its pos little by some offset while it is pressed.
Also you can change color of the item to give more realistic effect. Hope am getting u right ;)

bunjee
25th June 2009, 11:45
Solved : QGraphicsItem::isUnderMouse()


void qwListGraphicsItem::mouseReleaseEvent(QGraphicsSce neMouseEvent * event)
{
Q_D(qwListGraphicsItem);

if (isUnderMouse() == false) return;

// Do something...
}