在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);}新闻热点
疑难解答