//.c文件
#include pplication> #include <QLabel> #include <QMovie> #include <QPushButton> #include <QFont> #include "qt_movie_1.h"
void MyMainWindow::my_pause() { movie->setPaused(TRUE); } void MyMainWindow::my_unpause() { movie->setPaused(FALSE); }
void MyMainWindow::my_setspeed() { if(num == 100) { num += 100; movie->setSpeed(num); } else if(num == 200) { num += 100; movie->setSpeed(num); } else { num = 100; movie->setSpeed(num); } }
MyMainWindow::MyMainWindow() { setGeometry(100, 100, 200, 300);
num = 100; //const QMovie movie("0019.gif"); movie = new QMovie("0019.gif"); movie->start(); label = new QLabel(this); label->setGeometry(10, 10, 120, 60); label->setMovie(movie);
b1 = new QPushButton("pause", this); b1->setGeometry(10, 80, 120, 60); b1->setFont(QFont("Times", 10, QFont::Bold));
b2 = new QPushButton("continue", this); b2->setGeometry(10, 160, 120, 60); b2->setFont(QFont("Times", 10, QFont::Bold)); b3 = new QPushButton("change speed", this); b3->setGeometry(10, 240, 120, 60); b3->setFont(QFont("Times", 10, QFont::Bold)); connect(b1, SIGNAL(clicked()), this, SLOT(my_pause())); connect(b2, SIGNAL(clicked()), this, SLOT(my_unpause())); connect(b3, SIGNAL(clicked()), this, SLOT(my_setspeed())); }
int main(int argc, char **argv) { QApplication a(argc, argv); MyMainWindow w; // a.setMainWidget(&w); //qt4中不用这个了,没有主窗口的概念了。
w.show(); a.exec(); return 0; }
qt4.3.5下编译的,
qmake -v 看一下是不是 4.3.5版本,
如果是的话
$qmake -project
$qmake
$make
就可以了,要是3.1版本的,就要稍加修改一下了
|