thank you very much.I changed the above code, As follows:But didn't work.
#include "lines.h"
#include <QPainter>
#include <QTimer>
{
}
{Q_UNUSED(e);
red(&qp);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);
blue(&qp);
}
{
qp->setBrush(brush);
qp->drawRect(200,200,200,200);
}
{
pa->setBrush(brush);
pa->drawRect(200,200,200,200);
}
#include "lines.h"
#include <QPainter>
#include <QTimer>
Lines::Lines(QWidget *parent)
: QWidget(parent)
{
}
void Lines::paintEvent(QPaintEvent *e)
{Q_UNUSED(e);
QPainter qp(this);
red(&qp);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);
blue(&qp);
}
void Lines::red(QPainter*qp)
{
QBrush brush(Qt::blue);
qp->setBrush(brush);
qp->drawRect(200,200,200,200);
}
void Lines::blue(QPainter*pa)
{
QBrush brush(Qt::red);
pa->setBrush(brush);
pa->drawRect(200,200,200,200);
}
To copy to clipboard, switch view to plain text mode
Bookmarks