演示效果:
1.先添加MFC导出库到QT工程
2.添加按钮并连接到槽
3.在槽函数中使用QLibrary类来加载MFC导出库
槽函数实现源码:
FUNC ShowDlg;
wchar_t title[]=L"QT 中调用MFC DLL 的导出函数";
QLibrary lib("TestLibMfc");
if(lib.load()){
ShowDlg = (FUNC)lib.resolve("ShowDlg");
if(!ShowDlg){
lib.unload();
QMessageBox::information(this,NULL,"get function address from mfc dll TestLibMfc.dll fail");
}else{
ShowDlg(title);
lib.unload();
}
}else{
QMessageBox::information(this,NULL,"load mfc dll TestLibMfc.dll fail");
}