QWidget *xxx= QWidgetFactory::create("QAiredaleForm", 0, 0);
#include "pluginmanager.h"#include <qdir.h>#include <qlibrary.h>#include <qstringlist.h>CPluginManager::CPluginManager(QString dirPath,QWidget* pWnd){ m_dirPath=dirPath; m_pparentWindow=pWnd;}bool CPluginManager::load(){ QDir dir(m_dirPath); if(!dir.exists()) return false; const QFileInfoList* files = dir.entryInfoList("*.so *.dll",QDir::Files); if(!files) return false; QFileInfoListIterator it( *files ); QFileInfo * fi; while((fi=it.current())!=0) { ++it; QString file = fi->fileName(); //remove lib prefix if(file.left(3) == "lib") file.remove(0,3); if(file.left(2)!="ie" ) continue; file=fi->baseName(); //remove lib prefix#ifndef Q_WS_WIN file.remove(0,3);#endif file=m_dirPath+"/"+file; QLibrary lib(file); if(!lib.load()) continue; typedef CIEBasePlugin* (*pf)(); pf plugin = (pf)lib.resolve("getPlugin"); if( plugin==NULL ) continue; funInfo fInfo; fInfo.pFun = plugin(); fInfo.pFun->getFunctionName(fInfo.funName); fInfo.pFun->getFunctionNameMenu(fInfo.menuName); fInfo.pFun->getFunctionPriority(fInfo.priority); fInfo.pFun->getFunctionMenuSub(fInfo.menuSub); m_funInfo.append(fInfo); qDebug("Load plugins: %s, function: %s,menu sub: %s, menu name: %s, priority: %d",file.latin1(),fInfo.funName.latin1(),fInfo.menuSub.latin1(),fInfo.menuName.latin1(),fInfo.priority); } return true;}bool CPluginManager::unload(){ return true;}
QWidget *xxx= factory.createWidget( "QAiredaleForm", this, "AiredaleForm");