{
int side = qMin(width(), height());
static int i = 0, j =0;
static int flag = 1;
int diameter;
if(j<420)
{
j++;
}
else
{
printf("\nThe cleint exited");
exit(0);
}
painter.
setRenderHint(QPainter::Antialiasing);
side =qMin(width(),height() );
painter.translate(side / 2, side / 2);
painter.drawRect(-side/2,-side/2,side,side);
painter.
fillRect(QRect(-side
/2,
-side
/2,side,side
),
QBrush(Qt
::black));
};
painter.
setPen(QPen(Qt
::green,
1,Qt
::DotLine));
painter.drawLines(points,2);
painter.
setPen(QPen(Qt
::green));
painter.drawText(420,0,"60.0");
painter.drawText(350,0,"50.0");
painter.drawText(280,0,"40.0");
painter.drawText(210,0,"30.0");
painter.drawText(140,0,"20.0");
painter.drawText(70,0,"10.0");
painter.save();
painter.restore();
painter.
setPen(QPen(Qt
::green));
for (diameter = 140; diameter<=840; diameter+=140)
{ painter.
drawEllipse(QRect(-diameter
/ 2,
-diameter
/ 2,
diameter, diameter));
}
painter.
setPen(QPen(Qt
::black));
for(i = 1; i <= 420; i= i+5)
{
if(flag == 1)
{
painter.
setBrush(QBrush(Qt
::red,Qt
::SolidPattern));
flag = 0;
}
else
{
painter.
setBrush(QBrush(Qt
::blue,Qt
::SolidPattern));
flag = 1;
}
painter.
drawEllipse(QRect(i,j,
10,
10));
painter.
drawEllipse(QRect(-i,j,
10,
10));
painter.
drawEllipse(QRect(i,
-j,
10,
10));
painter.
drawEllipse(QRect(-i,
-j,
10,
10));
}
painter.end();
}
void AnalogClock::paintEvent(QPaintEvent *)
{
int side = qMin(width(), height());
static int i = 0, j =0;
static int flag = 1;
int diameter;
if(j<420)
{
j++;
}
else
{
printf("\nThe cleint exited");
exit(0);
}
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
side =qMin(width(),height() );
painter.translate(side / 2, side / 2);
painter.drawRect(-side/2,-side/2,side,side);
painter.fillRect(QRect(-side/2,-side/2,side,side),QBrush(Qt::black));
static const QPointF points[4] = {
QPointF(0,-side/2),
QPointF(0,side/2),
QPointF(-side/2,0),
QPointF(side/2,0)
};
painter.setPen(QPen(Qt::green,1,Qt::DotLine));
painter.drawLines(points,2);
painter.setPen(QPen(Qt::green));
painter.drawText(420,0,"60.0");
painter.drawText(350,0,"50.0");
painter.drawText(280,0,"40.0");
painter.drawText(210,0,"30.0");
painter.drawText(140,0,"20.0");
painter.drawText(70,0,"10.0");
painter.save();
painter.restore();
painter.setPen(QPen(Qt::green));
for (diameter = 140; diameter<=840; diameter+=140)
{ painter.drawEllipse(QRect(-diameter / 2, -diameter / 2,
diameter, diameter));
}
painter.setPen(QPen(Qt::black));
for(i = 1; i <= 420; i= i+5)
{
if(flag == 1)
{
painter.setBrush(QBrush(Qt::red,Qt::SolidPattern));
flag = 0;
}
else
{
painter.setBrush(QBrush(Qt::blue,Qt::SolidPattern));
flag = 1;
}
painter.drawEllipse(QRect(i,j,10,10));
painter.drawEllipse(QRect(-i,j,10,10));
painter.drawEllipse(QRect(i,-j,10,10));
painter.drawEllipse(QRect(-i,-j,10,10));
}
painter.end();
}
To copy to clipboard, switch view to plain text mode
Bookmarks