希望在运行过程中对插件的原始文件进行操作,
但插件卸载成功后,文件覆盖删除操作都失败。
插件很简单,没有生成任何额外对象
#ifndef DATAVIEWER_H
#define DATAVIEWER_H
#include <QDebug>
#include "iplugin.h"
class DataViewer : public QObject, public IPlugin
{
Q_OBJECT
Q_INTERFACES(IPlugin)
Q_PLUGIN_METADATA(IID iid_flower FILE "DataViewer.json")
public:
DataViewer(QObject *parent = 0):QObject(parent){
// qDebug() <<"create";
}
~DataViewer(){
// qDebug() << "delete";
}
bool initialize(){return true;}
bool extensionsInitialized(){return true;}
bool stop(){return true;}
void recMsg(PluginMetaData){}
signals:
void sendMsg(PluginMetaData);
};
#endif // DATAVIEWER_H
插件加载后即下载,然后删除文件失败
#include <QCoreApplication>
#include <QPluginLoader>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QPluginLoader load("D:/Project/Qt/Flower/debug/plugins/DataViewer.dll");
qDebug()<<load.load();
qDebug()<<load.unload();
qDebug()<<QFile::remove("D:/Project/Qt/Flower/debug/plugins/DataViewer.dll");
return a.exec();
}
输出
true
true
false