您的位置:首页 > 编程语言 > Qt开发

设置Qt依赖库路径

2017-02-28 14:41 1781 查看
在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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Qt库找不到