Hello, in this program I want to blinking of the rectangle.in this way: First, Blue rectangle show.and after 500 msec,Red rectangle show.but, when I run this program,I see A high pause and then red rectangle show and Not Blink well.
#include "lines.h"
#include <QPainter>
#include <QThread>
{
}
{
for(int i=1;i<=10;i++)
{
Q_UNUSED(e);
qp.setBrush(brush);
qp.drawRect(100,100,200,200);
brush.setColor(Qt::red);
qp.setBrush(brush);
qp.drawRect(100,100,200,200);
}}
#include "lines.h"
#include <QPainter>
#include <QThread>
Lines::Lines(QWidget *parent)
: QWidget(parent)
{
}
void Lines::paintEvent(QPaintEvent *e)
{
for(int i=1;i<=10;i++)
{
Q_UNUSED(e);
QPainter qp(this);
QBrush brush(Qt::blue);
qp.setBrush(brush);
qp.drawRect(100,100,200,200);
QThread::msleep(500);
brush.setColor(Qt::red);
qp.setBrush(brush);
qp.drawRect(100,100,200,200);
}}
To copy to clipboard, switch view to plain text mode
Bookmarks