Context Menu event with QGraphicsWidget
        Posted  
        
            by onurozcelik
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by onurozcelik
        
        
        
        Published on 2010-06-10T09:17:06Z
        Indexed on 
            2010/06/10
            12:22 UTC
        
        
        Read the original article
        Hit count: 247
        
In my application I subclass QGraphicsWidget
In paint I am drawing a line with pen width 4.
I reimplemented boundingRect() and shape().
But I can't catch context menu event every time I click right mouse button.
What is the problem.(Pen Width ? )
 //Sample code for boundingRect() and shape()
  QRectF boundingRect() const
  {
    qreal rectLeft = x1 < x2 ? x1 : x2;
    qreal rectTop = y1 < y2 ? y1 : y2;
    qreal rectWidth = (x1 - x2) != 0 ? abs(x1-x2) : 4;
    qreal rectHeight = (y1 - y2) != 0 ? abs(y1 -y2) : 4;
    return QRectF(rectLeft,rectTop,rectWidth,rectHeigt);
  }
  QPainterPath shape()
  {
    QPainterPath path;
    path.addRect(boundingRect());
    return path;
  }
© Stack Overflow or respective owner