Results 1 to 5 of 5

Thread: Context Menu event with QGraphicsWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Location
    Turkey
    Posts
    39
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Context Menu event with QGraphicsWidget

    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 ? )

    Qt Code:
    1. //Sample code for boundingRect() and shape()
    2.  
    3. QRectF boundingRect() const
    4. {
    5. qreal rectLeft = x1 < x2 ? x1 : x2;
    6. qreal rectTop = y1 < y2 ? y1 : y2;
    7. qreal rectWidth = (x1 - x2) != 0 ? abs(x1-x2) : 4;
    8. qreal rectHeight = (y1 - y2) != 0 ? abs(y1 -y2) : 4;
    9.  
    10. return QRectF(rectLeft,rectTop,rectWidth,rectHeigt);
    11. }
    12.  
    13. QPainterPath shape()
    14. {
    15. path.addRect(boundingRect());
    16. return path;
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by onurozcelik; 10th June 2010 at 10:13. Reason: updated contents

Similar Threads

  1. Context Menu & QGraphicsWidget
    By onurozcelik in forum Qt Programming
    Replies: 4
    Last Post: 12th May 2010, 12:08
  2. Context menu
    By dejvis in forum Newbie
    Replies: 2
    Last Post: 20th September 2009, 22:02
  3. Separator in context menu
    By schall_l in forum Qt Programming
    Replies: 3
    Last Post: 18th June 2009, 17:09
  4. Qwt and context menu
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 9th December 2008, 08:55
  5. Context Menu
    By RY in forum Newbie
    Replies: 1
    Last Post: 10th September 2008, 07:59

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.