解決方案:QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins,qcoreapplication

來源:互聯網
上載者:User

解決方案:QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins,qcoreapplication

在用QSqlDatabase時遇到報錯QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins是因為Qt不知道plugins的所在目錄。


解決方案:

在用到資料庫之前添加代碼QCoreApplication::addLibraryPath("./plugins");

其中的"./plugins"可以替換為實際plugins所在的目錄(plugins下級存在sqldrivers目錄,該目錄下的dll為QSqlDatabase實際需要的library。




相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.