hi all,
I wrote some objects derived from QGraphicsView and QGraphicsItem, and I simulate a mouse click event in my QGraphicsItem just like this
{
// if(e->buttons() == Qt::LeftButton)
// SetButtonState(NORMAL);
setSelected(false); // i don't need the focus
QRectF bRect
= boundingRect
();
if(bRect.contains(lastpt))
; // ??? It's a click event.
}
void QMyItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
{
// if(e->buttons() == Qt::LeftButton)
// SetButtonState(NORMAL);
QGraphicsPixmapItem::mousePressEvent(event);
setSelected(false); // i don't need the focus
QPointF lastpt = event->lastPos();
QRectF bRect = boundingRect ();
if(bRect.contains(lastpt))
; // ??? It's a click event.
}
To copy to clipboard, switch view to plain text mode
My question is, how can i track the mouse 'click' event in my QGraphicsView? in other words, i need to integrate these mouse events in QGraphicsView and find which item activate it,
void QMyGraphicsView::Command( param)
{
switch(param)
{
case ?? : ...
case ?? : ...
}
...
}
void QMyGraphicsView::Command( param)
{
switch(param)
{
case ?? : ...
case ?? : ...
}
...
}
To copy to clipboard, switch view to plain text mode
or is there a better place to dispose other than QGraphicsView?
thanks for any advice.
Bookmarks