nightroad
12th July 2011, 20:16
Hi there,
I'm trouble with QPainterPath::subtracted function, i made a little sample like that
QPainterPath path;
QPainterPath path;
path.moveTo(100,200);
path.lineTo(250,200);
path.moveTo(250,200);
path.lineTo(300,200);
painter->drawPath( path );
QPainterPath path2;
QPen pen2 ( QBrush(Qt::red), 6 );
painter->setPen( pen2 );
painter->setBrush(brush());
path2.moveTo(120,200);
path2.lineTo(260,200);
painter->drawPath( path2 );
QPen pen3 ( QBrush(Qt::green), 3 );
painter->setPen( pen3 );
painter->setBrush(brush());
QPainterPath popo = path.subtracted( path2 );
if ( popo != path )
painter->drawPath( popo );
popo is always equal to path ? am i doing something wrong ?
Added after 49 minutes:
Oh my mistake, QPainterPath::subtracted is doing fill area's subtraction. Lines don't have filled area at all then it's not working as i expect. Anyway is there any idea how can i subtract which is consisted lines QPainterPath with another QPainterPath which is also consisted lines ..
I'm trouble with QPainterPath::subtracted function, i made a little sample like that
QPainterPath path;
QPainterPath path;
path.moveTo(100,200);
path.lineTo(250,200);
path.moveTo(250,200);
path.lineTo(300,200);
painter->drawPath( path );
QPainterPath path2;
QPen pen2 ( QBrush(Qt::red), 6 );
painter->setPen( pen2 );
painter->setBrush(brush());
path2.moveTo(120,200);
path2.lineTo(260,200);
painter->drawPath( path2 );
QPen pen3 ( QBrush(Qt::green), 3 );
painter->setPen( pen3 );
painter->setBrush(brush());
QPainterPath popo = path.subtracted( path2 );
if ( popo != path )
painter->drawPath( popo );
popo is always equal to path ? am i doing something wrong ?
Added after 49 minutes:
Oh my mistake, QPainterPath::subtracted is doing fill area's subtraction. Lines don't have filled area at all then it's not working as i expect. Anyway is there any idea how can i subtract which is consisted lines QPainterPath with another QPainterPath which is also consisted lines ..