I changed the above code, As follows: and only I want to paint a rectangle by blue and I want to delay 1000 msec for it and also such as Traffic Lights, It is Blinking
#include <QWidget>
{
Q_OBJECT
public:
protected:
public slots:
};
#include <QWidget>
class Lines : public QWidget
{
Q_OBJECT
public:
Lines(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event);
public slots:
void blue(QPainter*pa);
};
To copy to clipboard, switch view to plain text mode
#include "lines.h"
#include <QPainter>
#include <QTimer>
{
connect(timer,
SIGNAL(timeout
()),
this,
SLOT(blue
(QPainter*pa
)));
timer->start(1000);
}
{Q_UNUSED(e);
blue(&qp);
}
{
pa->setBrush(brush);
pa->drawRect(200,200,200,200);
}
#include "lines.h"
#include <QPainter>
#include <QTimer>
Lines::Lines(QWidget *parent)
: QWidget(parent)
{
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(blue(QPainter*pa)));
timer->start(1000);
}
void Lines::paintEvent(QPaintEvent *e)
{Q_UNUSED(e);
QPainter qp(this);
blue(&qp);
}
void Lines::blue(QPainter*pa)
{
QBrush brush(Qt::blue);
pa->setBrush(brush);
pa->drawRect(200,200,200,200);
}
To copy to clipboard, switch view to plain text mode
Added after 1 15 minutes:
Mr anda skoa, Mr wysota and other Mr, please help me.this post is not a spam.
Bookmarks