需要注意的是要在main.cpp文件里面加上插件路径,我给你发一下我添加路径的代码吧。
#include "MainDialog.h"
#include <QApplication>
#include <windows.h>
#include <QDir>
int main(int argc, char *argv[])
{
char path[256] = {0};
GetSystemDirectoryA(path, sizeof(path) / sizeof(char));
QString qpath(path);
qpath.append(QLatin1String("\\QtPlugins"));
QDir dir(qpath);
if(dir.exists("plugins"))
qpath.append("\\plugins");
QApplication::addLibraryPath(qpath);
QApplication a(argc, argv);
MainDialog w;
w.show();
return a.exec();
}
楼主傻了,直接把Qt的发行版的dll打个自解压到system32目录的包,还有把插件之类的都加上去解压到系统指定的目录,让没有安装过你的运行库的电脑安装一下,以后你给别人发行软件,就直接给他一个一两百KB的exe程序就可以了,都不用考虑dll的问题,我发一个我打包的Qt5.1.1运行库的包,给你看看吧。
http://yunpan.cn/QG9xDMcGhYbRk
,总共才31M大小,插件是解压到system32\QtPlugins里面。解压过程是静默解压的,安装完后,你可以在system32目录里面找到Qt5.1.1的dll。
http://tieba.baidu.com/p/2393847613