QT 播放 FLASH

pamxy發表於2013-07-28

轉自:http://misterlanbing.blog.163.com/blog/static/203511084201232084414774/

/*

 *main.cpp

 */


#include <QApplication>

#include <QAxWidget.h>

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"));
   
 DisFlash Display;
 Display.show();
   
 return a.exec();
   
}

 

/*

 *QAxWidget.h

 */
 
#include <QtGui>
#include <QAxWidget>
#include <QMainWindow>


class DisFlash : public QMainWindow
{
 Q_OBJECT
  
public:
 DisFlash(void);
// ~DisFlash();

private slots:
 void Openfile(void);
 void Flashaction(QString command,QString args);


private:
 QString filepath;

 QAxWidget *Flash;
 QMenu *Operation;

 QAction *open;
 QAction *exit;

};

 

/*

 *QAxWidget.cpp

 */


#include <QtGui>
#include <QAxWidget>
#include "QAxWidget.h"

DisFlash :: DisFlash(void)
{
 resize(600,400);

 Flash = new QAxWidget(this);
 Flash->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}"));
 setCentralWidget(Flash);
 connect(Flash,SIGNAL(FSCommand(QString,QString)),this,SLOT(Flashaction(QString,QString)));

 open = new QAction(tr("開啟"),this);
 connect(open,SIGNAL(triggered()),this,SLOT(Openfile()));
 exit = new QAction(tr("退出"),this);
 connect(exit,SIGNAL(triggered()),this,SLOT(close()));
 Operation = menuBar() -> addMenu(tr("File"));
 Operation -> addAction(open);
 Operation -> addAction(exit);

 filepath = "./";                //初始路徑為當前目錄
}

void DisFlash :: Openfile(void)
{
 filepath = QFileDialog :: getOpenFileName(this,tr("Open File"),filepath,"*.swf");
 Flash->dynamicCall("LoadMovie(long,string)",0,filepath);
}

void DisFlash :: Flashaction(QString command,QString args)
{

}

 

在 pro 檔案中新增 CONFIG+=qaxcontainer

(轉者注:即新增上QAxContainerd.lib)

 

 播放介面

QT 顯示 FLASH - misterlanbing - misterlanbing的部落格

相關文章