设置Qt依赖库路径

来源:互联网 发布:php生成短网址 编辑:程序博客网 时间:2024/06/15 01:10

在Qt5.0版本以后,由于框架的改动,打包的程序安装到其它电脑会提示找不到Qt库的路径, 这时候需要注册这些库,如下:

void Util::registerPluginsDir(QDir &exeDir){    QString pluginsRelPath = "qtplugins";    QString platformsRelPath = "platforms";    QString sqlDriversRelPath = "sqldrivers";    QString imageformatsRelPath = "imageformats";    QString pluginsPath = exeDir.absoluteFilePath(pluginsRelPath);    QString platformsPath = QDir(pluginsPath).absoluteFilePath(platformsRelPath);    QString sqlDriversPath = QDir(pluginsPath).absoluteFilePath(sqlDriversRelPath);    QString imageformatsPath = QDir(pluginsPath).absoluteFilePath(imageformatsRelPath);    QStringList pathes = QCoreApplication::libraryPaths();    pathes << pluginsPath;    pathes << platformsPath;    pathes << sqlDriversPath;    pathes << imageformatsPath;    QCoreApplication::setLibraryPaths(pathes);}
0 0