[Qt-interest] drawing polyline with QPainterPath

Sean Harmer sean.harmer at maps-technology.com
Tue Jun 2 11:34:33 CEST 2009


Hi,

On Tuesday 02 Jun 2009 10:22:28 Jan wrote:
> Hi,
>
> > if ( !m_fillPath )
> > {
> >     path.moveTo( pPrime.at( 0 ) );
> >     for ( int i = 1; i < pPrime.size(); ++i )
> >         path.lineTo( pPrime.at( i ) );
> > }
>
> I tried this before (which did not work i.e. it's still an area).
Oh yeah now I remember, the "trick" is to not set a brush on the painter when 
drawing the path. If a brush is set the path always seems to want to have a 
fill.

> I am still trying to understand/work with the second part .-)
In my second part I explicitly create a closed path by calling closeSubPath() 
is all. So is not directly relevant in your case but I included it for 
completeness.

Cheers,

Sean

>
> Thank you
> Jan
>
> > else
> > {
> >     // We need to construct a closed path
> >     QPointF zero( 0.0, 0.0 );
> >     QPointF zeroPrime = m_coordSystem->mapToPrimed( zero );
> >     path.moveTo( pPrime.at( 0 ).x(), zeroPrime.y() );
> >     for ( int i = 0; i < pPrime.size(); ++i )
> >         path.lineTo( pPrime.at( i ) );
> >     path.lineTo( pPrime.last().x(), zeroPrime.y() );
> >     path.closeSubpath();
> > }
> >
> > then later I simply call QPainter::drawPath(). You can ignore my
> > m_coordSystem object it simply transforms my data set into a more
> > convenient coordinate system.
> >
> > HTH,
> >
> > Sean
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list