Results 1 to 2 of 2

Thread: ClipRect is ignored when drawing a QPainterPath?

  1. #1
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default ClipRect is ignored when drawing a QPainterPath?

    Hi - here is my setup :
    I use a class directly derived from a plain QWigdet as my drawing area overriding paintEvent()
    I use a cosmetic pen, anitaliasing is NOT enabled.
    I use a clipRect set to the bounding rect of my QWidget.
    I draw a simple QPainterPath that has only moveTo and LineTo elements.
    The QPainterPath contains at most ~10000 elements.


    This is what happens:
    When I pouplate my QPainterPath with just enough items to fully cover my drawing area, paintEvents run smoothly.
    When I fill up the the Path with more Items painting performance degrades dramatically.

    This is my problem:
    The strange thing is, all the elements (Lines) I add are located outside the drawing area, so there should be no need to paint them anyway.
    I expected the qpainter.drawPath() method to be intelligent enough to skip painting of items outside the drawing surface?
    I was a bit surprised because I did a similar thing with Java/Swing/Generalpath. The painting enigne of Java obviously knew which parts of the path where visible and the performance degraded only marginally with the number of items in the GeneralPath.

    Any hints how to improve this?
    Do I have to implement a custom list of drawing items?
    Is the situation any different with the QGraphicsScene/View architecture?

    Thanks for reading

    Eberhard

  2. #2
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: ClipRect is ignored when drawing a QPainterPath?

    I'll answer myself..

    I dropped the QPainterPath approach in favor of a QVector<QLineF> which I manage myself. Works like a breeze.
    I just wonder what a QPainterPath is good for, if the painting system does not know which parts of the item are invisible and therefore don't need to be repainted.

    Thanks anyway
    Eberhard

Similar Threads

  1. QPainterPath::quadTo(...) calls QPainterPath::cubicTo(...) ?
    By brucelamond in forum Qt Programming
    Replies: 0
    Last Post: 29th April 2011, 00:30
  2. QPainterPath and scale()
    By edwardc in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2010, 11:03
  3. QPainterPath and QPolygon
    By Muz in forum Qt Programming
    Replies: 0
    Last Post: 18th September 2009, 08:16
  4. Advices for animating drawing of a QPainterPath?
    By Gnurou in forum Qt Programming
    Replies: 0
    Last Post: 4th July 2008, 16:17
  5. QPainterPath drawing problem
    By shad in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2007, 14:30

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.