Failed to load platform plugin "windows"
这个错误在双击exe执行时不会出现,当传递命令行参数时出问题 ,解决方法:
int main(int
argc,
char
*argv[])
{
Q_INIT_RESOURCE(rc);
//解决库路径问题[email protected]
QTextCodec *xcodec = QTextCodec::codecForLocale() ;
QString exeDir = xcodec->toUnicode( QByteArray(argv[0]) ) ;
QString BKE_CURRENT_DIR = QFileInfo(exeDir).path() ;
QStringList libpath;
libpath << BKE_CURRENT_DIR+QString::fromLocal8Bit("/plugins/platforms");
libpath << BKE_CURRENT_DIR <<BKE_CURRENT_DIR+QString::fromLocal8Bit("/plugins/imageformats");
libpath << BKE_CURRENT_DIR+QString::fromLocal8Bit("/plugins");
libpath << QApplication::libraryPaths();
QApplication::setLibraryPaths(libpath) ;
//=========================
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
时间: 2024-10-08 06:12:02