void line::paintEvent(QPaintEvent *c)
{
//lines
QPainter line(this);
line.setRenderHint(QPainter::Antialiasing,true);
line.setPen(QPen(Qt::black,2,Qt::SolidLine,Qt::RoundCap,Qt::MiterJoin));
line.setBrush(QBrush(Qt::black,Qt::SolidPattern));
line.drawLine(50,50,50,200); // Y axis
line.drawLine(50,200,250,200); // x axis
// rectangle
int a[5] ={20,60,120,30,200}; //length = a[]
int x= 50.0 ;
int y= 200 ;
int inc = 200/5;
for(int i=0 ; i<5 ;i++)
{
QRectF rect( (x + (i * inc)), (y - a[i]), (x + (i * inc) + 20), Y);
line.setPen(QPen(Qt::green,8,Qt::SolidLine,Qt::RoundCap,Qt::MiterJoin));
line.drawRect(rect);
}
}
|