MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
rect
= scene.
addRect(QRectF(0,
0,
100,
100),
QPen(), Qt
::black);
ui
->graphicsView
->setViewport
(new QGLWidget);
ui->graphicsView->setScene(&scene);
ui->graphicsView->show();
timeLine
->setCurveShape
(QTimeLine::LinearCurve);
timeLine->setFrameRange(0, 1000);
connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateRect(int)));
timeLine->start();
}
void MainWindow::updateRect(int frame)
{
if (frame % 2)
{
this->rect->setBrush(Qt::blue);
}
else
{
this->rect->setBrush(Qt::black);
}
this->rect->update();
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
rect = scene.addRect(QRectF(0, 0, 100, 100), QPen(), Qt::black);
ui->graphicsView->setViewport(new QGLWidget);
ui->graphicsView->setScene(&scene);
ui->graphicsView->show();
timeLine = new QTimeLine(40000, this);
timeLine->setCurveShape(QTimeLine::LinearCurve);
timeLine->setFrameRange(0, 1000);
connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateRect(int)));
timeLine->start();
}
void MainWindow::updateRect(int frame)
{
if (frame % 2)
{
this->rect->setBrush(Qt::blue);
}
else
{
this->rect->setBrush(Qt::black);
}
this->rect->update();
}
To copy to clipboard, switch view to plain text mode
Bookmarks