Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, December 2007
QGraphicsPathItem and mousePressEvent


Message 1 in thread

Hi.

I've the next code in a derived QGraphicsPathItem class that draws two sides 
of a triangle:

QPainterPath _line;
_line.moveTo(300, 300);
_line.lineTo(400,400);
_line.lineTo(500,300);
setPath(_line);

Also I've the next code in a derived QGraphicsScene class, in the 
mousePressEvent function:

QPointF mousePos(event->buttonDownScenePos(Qt::RightButton).x(), 
event->buttonDownScenePos(Qt::RightButton).y());
_sceneitem = itemAt(mousePos.x(), mousePos.y());

if (_sceneitem != 0 && event->button() == Qt::RightButton) {
    openMenu(_sceneitem);
}
    
clearSelection();    
QGraphicsScene::mousePressEvent(event);

I need to execute the function "openMenu()" ONLY if the mouse is over some 
side of the triangle (not in the inside area) and click right button. How can 
I do?

Thanks.

-- 
 [ signature omitted ]