QT 动态加载dll

声明函数

//typedef QWidget*(*Dllfun_GetMainDlg)();
//typedef void   (*Dllfun_SetChannelNames)(QString,QStringList);

调用

/*  mylib.setFileName("D:/QT/test7/build-CDBurner-5_5minw-Debug/debug/CDBurner.dll");
   if(mylib.load()){
        Dllfun_GetMainDlg GetMainDlg=(Dllfun_GetMainDlg)mylib.resolve("GetMainDlg");
        if (GetMainDlg)                  //是否成功连接上 函数
        {

            QWidget* back= GetMainDlg();      //这里函数指针调用dll中的 函数
            if(back){
                QWidget * mainWidget = ui->widget;
                QGridLayout * layout = new QGridLayout();
                layout->addWidget(back,0,0,1,1);
                mainWidget->setLayout(layout);
               // QMessageBox::information(NULL,"NO","GetMainDlg is loaded!");
            }else{
                QMessageBox::information(NULL,"NO","GetMainDlg back is not loaded!");
            }
        }
        else{
            QMessageBox::information(NULL,"NO","GetMainDlg is not loaded!");
        }
    }
    else{
        QMessageBox::information(NULL,"NO","DLL is not loaded!");
    }

*/


展开阅读全文

没有更多推荐了,返回首页