当我试图在另一台计算机上执行我的qt程序时,我会收到以下错误并崩溃:
Failed to load platform plugin "windows". Available platforms are:
windows我知道这个问题曾在其他几个问题中讨论过:
failed to load platform plugin "windows" Available platforms are: windows, minimal
Qt application: Failed to load platform plugin "windows". Available platforms are:
PyQt5 - Failed to load platform plugin "windows". Available platforms are: windows, minimal
但我已经应用了建议的解决方案,但对我来说还是行不通的。有关资料:
发布于 2014-01-21 11:18:32
我对qwindows.dll也有同样的问题-- win7 64 ok,win7 32失败,找不到qwindows.dll
首先,我检查了我是否可以使用-platformpluginpath运行它:
app.exe -platformpluginpath plugins/platforms 一切都很好,所以问题是在应用程序中搜索路径是错误的。最后,我只添加了所有可能的路径:
#include <QApplication>
#include <QDir>
void registerPluginsDir(QDir& exeDir)
{
#ifdef Q_OS_MAC
QString pluginsRelPath = "/../../PlugIns";
#elif defined(Q_OS_WIN)
QString pluginsRelPath = "Plugins";
#elif defined (Q_OS_LINUX)
QString pluginsRelPath = "../lib/plugins";
#else
#error "Unsupported OS"
#endif
QString platformsRelPath = "platforms";
QString pluginsPath = exeDir.absoluteFilePath(pluginsRelPath);
QString platformsPath = QDir(pluginsPath).absoluteFilePath(platformsRelPath);
QStringList pathes = QCoreApplication::libraryPaths();
pathes << pluginsPath;
pathes << platformsPath;
pathes << platformsRelPath;
pathes << pluginsRelPath;
QCoreApplication::setLibraryPaths(pathes);
}
int main(int argc, char *argv[])
{
QString exePath = QString::fromUtf8(argv[0]);
QFileInfo exeInfo (exePath);
QDir exeDir (exeInfo.absolutePath());
//need to set correct plugins path before app instance created
registerPluginsDir(exeDir);
QApplication app(argc, argv);
// more code here
return app.exec();
}https://stackoverflow.com/questions/20616292
复制相似问题