最近搞个GIF 动画到是容易 但是flash 却不是那么容易 折腾一下午终于成功了 FLASH文件关键是文件名和路径 我用了相对路径 测试成功.
#include
#include
#include
#include
#include
#include
#include
#include
//QAxObject * documents = word.querySubObject("Documents");
void gifplay(QLabel *label)
{
label->show(); }
void gifclose(QLabel *label)
{ label->close(); }
void flashplay(QAxWidget *flash) {
flash->show();
}
void flashclose(QAxWidget *flash)
{ flash->close();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("gb18030"));
//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("gb18030"));
// QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
QAxWidget *flash = new QAxWidget(0,0);
flash->resize(600,400);
flash->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}"));
QString name=qApp->applicationDirPath();
flash->dynamicCall("LoadMovie(long,string)",0,qApp->applicationDirPath()+"/flash1.swf");
flash->show();
return a.exec();
// QTextCodec *codec = QTextCodec::codecForName("GB2312"); //文本为GB2312编
// QTextCodec::setCodecForLocale(codec); //设置本地编码
// QTextCodec::setCodecForCStrings(codec); //设置字符串编码
// QTextCodec::setCodecForTr(codec);
/*
QAxWidget *flash = new QAxWidget(0,0); //QAxWidget使用的是ActiveX插件
flash->resize(800,600); //设置该控件的初始大小
flash->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}")); //设定控制器
flash->dynamicCall("LoadMovie(long,string)",0,"D:\\QT_test\\build-donghua-Desktop_Qt_5_7_0_MinGW_32bit-Debug\\flash1.swf"); //
//flash->dynamicCall("D:\\QT_test\\build-donghua-Desktop_Qt_5_7_0_MinGW_32bit-Debug\\flash1.swf",0,0); //
flash->setWindowFlags(Qt::FramelessWindowHint); //去除边框
//ui-> wInfoShow-> setPlainText( flash-> dynamicCall( "TotalFrames" ). toString());//获得属性
flash-> dynamicCall( "FrameNum" , 200 );//设置属性
flashplay(flash);
QTime t;
t.start();
while(t.elapsed()<50000)
{
QApplication::processEvents();
}
flashclose(flash); */
/*2016nian测试播放GIF 没有问题*/
/*
QMovie *movie;
movie = new QMovie(".\\gif1.gif");
QLabel *label=new QLabel ("", 0);
label->setGeometry( 300, 300, 500, 500 );
label->setMovie(movie);
label->setScaledContents(true);
movie->start();
gifplay(label);
QTime t;
t.start();
while(t.elapsed()<20000)
{
QApplication::processEvents();
}
gifclose(label);
*/
return a.exec();
}