首页 > 学院 > 开发设计 > 正文

设置Qt依赖库路径

2019-11-06 09:00:38
字体:
来源:转载
供稿:网友

在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);}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表