QT5 Failed to load platform plugin "windows" 终极解决方案 命令行问题

Failed to load platform plugin "windows"

 这个错误在双击exe执行时不会出现,当传递命令行参数时出问题 ,解决方法:

int main(int argc, char *argv[])

{
    Q_INIT_RESOURCE(rc);

//解决库路径问题============info@seatrix.com
    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();
}

QT5 Failed to load platform plugin "windows" 终极解决方案 命令行问题

上一篇:C# SocketHelper 源码


下一篇:CentOS安装Redis、PHPredis扩展及Redis配置文件详解