Results 1 to 8 of 8

Thread: Non-rectangle rubber band implementation [Solved]

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,324
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Non-rectangle rubber band implementation [Solved]

    I'm trying to implement a "lasso" type rubber band to allow users to select things from a QGraphicsView. A rectangle won't work, because the items don't always fall into a neat rectangular area free from other items.

    I have tried subclassing QRubberBand and adding a new Shape (Lasso) with custom paintEvent code and a QPainterPath to accumulate the mouse event points, but that is not working well. I can draw the "lasso", but there are also artifacts (one or more lines drawn from the window top left to the starting mouse point) which somehow seem to get inserted into the path.

    I've checked the mouse positions (as best one can do that in mouse event handlers) and they look OK, and I don't see any (0,0) points being inserted.

    I have looked through many of the previous posts here on rubber bands, and none of them seem to apply; they all deal with customizing the stock QRubberBand, not implementing a new one from scratch.

    So, can anyone point me to code which provides an example of a QPainterPath or polygon / polyline - based rubber band? Any drawing packages for example?
    Last edited by d_stranz; 30th June 2011 at 05:16.

Similar Threads

  1. Conditional rubber band selection in QGraphicsView
    By stevel in forum Qt Programming
    Replies: 5
    Last Post: 14th January 2011, 08:32
  2. How do I clear the rubber band after a selection is done
    By aarelovich in forum Qt Programming
    Replies: 1
    Last Post: 15th July 2010, 12:29
  3. Replies: 2
    Last Post: 17th June 2010, 13:38
  4. How to draw rubber band using XOR
    By lni in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2009, 12:13
  5. Rubber band artifacts?
    By mooreaa in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2008, 18:19

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.