#include "dialog.h" #include "ui_dialog.h" Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog),timer(new QTimer(this)) { ui->setupUi(this); scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); asc = new QAscensor(10,10,100,30); scene->addItem(asc); } Dialog::~Dialog() { delete ui; delete asc; delete scene; delete timer; } void Dialog::on_pushButton_clicked() { connect(timer,SIGNAL(timeout()),scene,SLOT(advance())); timer->start(1000); } void Dialog::on_pushButton_2_clicked() { timer->stop(); }