Karl123
16th June 2013, 13:53
Hi everybody!
I'm new in this forum and I hope you can help me.
I would like to draw a 3d pie slice with QPainterPath. See the SourceCode.
QPainter paint(this);
paint.setRenderHint(QPainter::Antialiasing,true);
paint.translate(width()/2, height()/2);
paint.setBrush(QColor(0,255,0,127));
QPainterPath paint4;
paint4.setFillRule(Qt::WindingFill);
paint4.moveTo(300,150);
paint4.arcTo(0,0,600,300,10,45);
paint4.lineTo(300,150);
paint4.lineTo(300,180);
paint4.arcTo(0,30,600,300,10,45);
paint4.lineTo(300,180);
int xw2 = 300 * cos(55*(M_PI/180));
int yw2 = -150 * sin(55*(M_PI/180));
xw2+=300;
yw2+=150;
QPainterPath paint5;
paint5.moveTo(xw2,yw2);
paint5.lineTo(xw2,yw2+30);
paint4.addPath(paint5);
int xw = 300 * cos(10*(M_PI/180));
int yw = -150 * sin(10*(M_PI/180));
xw+=300;
yw+=150;
QPainterPath paint6;
paint6.moveTo(xw,yw);
paint6.lineTo(xw,yw+30);
paint4.addPath(paint6);
paint.drawPath(paint4);
Unfortunately, I can't fill the sides of the pie slice with the given color.
Thank you for your help in advance.
I'm new in this forum and I hope you can help me.
I would like to draw a 3d pie slice with QPainterPath. See the SourceCode.
QPainter paint(this);
paint.setRenderHint(QPainter::Antialiasing,true);
paint.translate(width()/2, height()/2);
paint.setBrush(QColor(0,255,0,127));
QPainterPath paint4;
paint4.setFillRule(Qt::WindingFill);
paint4.moveTo(300,150);
paint4.arcTo(0,0,600,300,10,45);
paint4.lineTo(300,150);
paint4.lineTo(300,180);
paint4.arcTo(0,30,600,300,10,45);
paint4.lineTo(300,180);
int xw2 = 300 * cos(55*(M_PI/180));
int yw2 = -150 * sin(55*(M_PI/180));
xw2+=300;
yw2+=150;
QPainterPath paint5;
paint5.moveTo(xw2,yw2);
paint5.lineTo(xw2,yw2+30);
paint4.addPath(paint5);
int xw = 300 * cos(10*(M_PI/180));
int yw = -150 * sin(10*(M_PI/180));
xw+=300;
yw+=150;
QPainterPath paint6;
paint6.moveTo(xw,yw);
paint6.lineTo(xw,yw+30);
paint4.addPath(paint6);
paint.drawPath(paint4);
Unfortunately, I can't fill the sides of the pie slice with the given color.
Thank you for your help in advance.