Results 1 to 3 of 3

Thread: Can QRubberBand paint out of clipping area ?

  1. #1
    Join Date
    Oct 2009
    Posts
    16
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Can QRubberBand paint out of clipping area ?

    Hi guys,

    I have a code (which I can not change) which uses QRubberBand in order to show boundaries on a chart. I need to implement custom display of the rubber band. The code (which, again, I can not change) gets an instance of rubber band to use at initialization time. This means that I can inherit from QRubberBand, reimplement paintEvent method and provide object of my class as the rubber. The only problem I have now is that I need somehow to paint on the area which is a bit bigger than QRubberBand geometry. When I do the painting out of the clipping rectangle, its being clipped. So the question is actually, how can I access the clipping area which is used by painter. QPainter::setClipRect does not help

    Here is something close to what I'm trying to do (just to make it a bit clearer):

    Qt Code:
    1. void MyRubberBand::paintEvent(QPaintEvent * e)
    2. {
    3. QPainter painter(this);
    4. QRect rect = e->rect();
    5. rect.adjust(-10, -10, 10, 10);
    6.  
    7. painter.save();
    8. painter.setClipRect(rect);
    9. painter.fillRect(rect, Qt::blue);
    10. painter.restore();
    11. }
    To copy to clipboard, switch view to plain text mode 

    The code above will try to display blue rectangle which is 20 pixels greater in each dimention than the e->rect() (which I believe, is the clip rectangle). But the rectangle will be displayed clipped

    Any ideas ?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can QRubberBand paint out of clipping area ?

    What does your application do ? I dont see any need to QRubberBand.QRubberBand is usually used while making selections.
    From your post it seems you have a area / canvas thing on which user can draw. Am I getting it right ?

  3. #3
    Join Date
    Oct 2009
    Posts
    16
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can QRubberBand paint out of clipping area ?

    Quote Originally Posted by aamer4yu View Post
    What does your application do ? I dont see any need to QRubberBand.QRubberBand is usually used while making selections.
    From your post it seems you have a area / canvas thing on which user can draw. Am I getting it right ?
    Not exactly, the application shows graph charts. User can soom-in / zoom-out by selecting an area on the chart. I use KDChart library to display the chart, and the KDChart library in its turn uses QRubberBand for displaying the zooming area. In my task Y axis zooming should be disabled. I managed to make KDChart to disable Y axis zoom, but the rubber area is still displayed as a rectangle, not as two parallel vertical lines (well, I want to display it as a semitransparent rectangle with height of the full chart and width as specified by used via mouse click/drag-drop). I can display the rubber as I want but the result picture is then being clipped. I want to somehow disable / tweak this clipping.

    So just to reiterate:
    1. I have to use QRubberBand (its already used and I can not do anything with this)
    2. The only direction to go for me seems to be inheriting from QRubberBand and reimplementing paintEvent
    3. To make all that I need to disable QPainter clipping. But I can not find a way to do that.

    Hope its clearer now.

Similar Threads

  1. Use of QRubberBand
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2009, 12:59
  2. Qwt 5.1 + Qt 4.5 - SVG no clipping
    By giusepped in forum Qwt
    Replies: 12
    Last Post: 13th April 2009, 17:43
  3. Using QRubberBand class?!?!?
    By nupul in forum Newbie
    Replies: 3
    Last Post: 1st April 2006, 17:19
  4. PrimitiveElemet's Paint Area
    By derick in forum Qt Programming
    Replies: 1
    Last Post: 1st February 2006, 15:52
  5. QRubberBand painting in the scroll area widget
    By SkripT in forum Qt Programming
    Replies: 7
    Last Post: 17th January 2006, 16:48

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.