Results 1 to 3 of 3

Thread: Understanding QPainterPath::simplified()

  1. #1
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Understanding QPainterPath::simplified()

    Hello.
    My implementation of 'paintEvent' is giving a particular result:

    Qt Code:
    1. void Widget::paintEvent( QPaintEvent * event )
    2. {
    3. QPainter p ( this );
    4. p.setPen( QPen( QBrush( Qt::darkRed ), 2 ) );
    5. p.setBrush( QBrush( Qt::gray ) );
    6.  
    7. QPainterPath myPath;
    8. myPath.moveTo( 600.0, 250.0 );
    9. myPath.cubicTo( 90.0, 50.0, 0.0, 50.0, 50.0, 370.0 );
    10. myPath.cubicTo( 140.0, 20.0, 10.0, 10.0, 600.0, 250.0 );
    11.  
    12. myPath.addRect( 10.0, 300.0, 160.0, 34.0 );
    13.  
    14. QPainterPath result ( myPath.simplified() );
    15. p.drawPath( result );
    16. }
    To copy to clipboard, switch view to plain text mode 

    Looking like this:


    Shouldn't the intersected region between the rectangle and the bezier path be filled in the path generated by the 'simplified' call?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Understanding QPainterPath::simplified()

    What fill mode do you have set on the path?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: Understanding QPainterPath::simplified()

    Hello.
    I'm using WindingFill, but in any case I tested with either of the fill modes and the result is the same.

    According to some more research, QPainterPath::simplified will output a path that looks the same as the original when painted.
    So for "moveTo" elements like that rectangle I can create a temporary path and then unite both as a boolean operation.
    Additionally, QPainterPath::simplified will convert that path which originally has 7 elements into a 145 "lineTo" elements path that is an approximation, so it won't work for what I want.

    This is the result from QPainterPath::simplified:


    I'll try something with a computational geometry library, and then feed the results back to Qt for rendering.

Similar Threads

  1. simplified alternative
    By wirasto in forum Newbie
    Replies: 4
    Last Post: 23rd October 2013, 08:07
  2. Simplified problem about enums and QVariants.
    By hickscorp in forum Qt Programming
    Replies: 5
    Last Post: 9th August 2011, 10:50
  3. QPainterPath::quadTo(...) calls QPainterPath::cubicTo(...) ?
    By brucelamond in forum Qt Programming
    Replies: 0
    Last Post: 28th April 2011, 23:30
  4. QString sth between trimmed and simplified
    By pmlody in forum Qt Programming
    Replies: 3
    Last Post: 3rd November 2009, 08:13
  5. Problems with QString::simplified() API
    By montylee in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2009, 04:14

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.