Results 1 to 4 of 4

Thread: How to use QPainterPathStroker?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to use QPainterPathStroker?

    Hi,

    I need to create an outline following a curve with a fixed width (said 100), as shown in my attachment 1.

    To do this, I use QPainterPathStroker using following code. However, the resulting stroker joins them with the curve (see attachment 2). What I want is the outline without joining with the curve. How can I do so? Thanks!

    Qt Code:
    1. QVector<QPointF> myCurve; // <-- myCurve is calculated somewhere else.
    2.  
    3. QPainterPath curvePath;
    4. curvePath.moveTo( myCurve[ 0 ] );
    5. for ( int idx = 1; idx < myCurve.size(); idx++ ) {
    6. curvePath.lineTo( myCurve[ idx ] );
    7. }
    8.  
    9. stroker.setCapStyle( Qt::RoundCap );
    10. stroker.setJoinStyle( Qt::RoundJoin );
    11. stroker.setWidth( 100 );
    12. QPainterPath outline = stroker.createStroke ( curvePath );
    13. painter->drawPath( outline );
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    • File Type: png 1.png (3.0 KB, 77 views)
    • File Type: png 2.png (7.1 KB, 75 views)

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.