看了一下Qt的文档QUILoader有一个添加addPluginPath 方法:说明如下:
Adds the given path to the list of paths in which the loader will search when locating plugins.
又找到一个地方:
To make a custom widget available to the loader, you can use the addPluginPath() function; to remove all available widgets, you can call the clearPluginPaths() function.
我的理解按文档说的是指定插件的路径可以加载自定义控件的。
贴上代码:
loader.addPluginPath("E:\\code\\qt\\csgui\\release\\"); //我编译的插件dll的路径
QWidget* w = loader.load(&file);
CCSTableView* pView = w->findChild<CCSTableView*>("cCSTableView");
pView->open();
w->show();
修改了代码仍然不行!。 将路径改为E:\\code\\qt\\csgui\\release\\xxx.dll也是一样。没有任何改变。
我自定义的控件的信号槽全部失败,以下是load时提示的调试信息:
Object::connect: No such signal QTableView::queryModel(QString,bool)
Object::connect: (sender name: 'cCSTableView')
Object::connect: (receiver name: 'cCSDataModel')
Object::connect: No such slot QTableView::setOpen(bool)
Object::connect: (sender name: 'pushButton')
Object::connect: (receiver name: 'cCSTableView')
Object::connect: No such slot QTableView::setOpen(bool)
Object::connect: (sender name: 'checkBox')
Object::connect: (receiver name: 'cCSTableView')