Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Deploy qt desktop app 'Driver not loaded'
Forum Updated to NodeBB v4.3 + New Features

Deploy qt desktop app 'Driver not loaded'

Scheduled Pinned Locked Moved Solved Installation and Deployment
24 Posts 3 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AdrianN17
    wrote on last edited by AdrianN17
    #21

    Change my odbc conection

    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
        db.setDatabaseName("Driver={MySQL ODBC 8.0 ANSI Driver};Server=localhost;DATABASE=tunqui_restaurante;");
        db.setUserName("root");
        db.setPassword("");
    

    and my query

    //if (query.size()>0) comment this line
        {
     while(query.next())
            {
                us.set_ID_usuario(query.value("ID_usuario").toInt());
                us.set_nombre(query.value("nombre").toString());
                us.set_apellido(query.value("apellido").toString());
                us.set_dni(query.value("dni").toString());
                us.set_telefono(query.value("telefono").toString());
                us.set_correo(query.value("correo").toString());
                us.set_cargo(query.value("cargo").toInt());
                us.set_direccion(query.value("direccion").toString());
    
            }
    //}
    

    ODBC conection work fine and I can log in my app (error code fixed)

    But when I deploy with windeployqt I had the same problem with QMYSQL

    windeployqt command : windeployqt restaurante_tunqui.exe

    alt text

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AdrianN17
      wrote on last edited by AdrianN17
      #22

      I found the solution:

          
      #include "controlador.h"
      #include "qmessagebox.h"
      
      controlador::controlador()
      {
      
      }
      
      static QSqlDatabase con=conexion().conecta();
      

      to

      usuario controlador::logear(acceso ac)
      {
          usuario us= usuario();
      
          QSqlDatabase con=conexion().conecta();
      
          QSqlQuery query(con);
      
      #include "vistas/login.h"
      #include <QApplication>
      
      int main(int argc, char *argv[])
      {
          QApplication::libraryPaths();
          QApplication a(argc, argv);
          login w;
          w.show();
      
          return a.exec();
      }
      

      https://forum.qt.io/topic/66480/deploy-on-windows/14

      I think because static db conection, windeployqt work fine

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #23

        There's really no need for any static (nor class variable) QDatabase object. QDatabase already provide all methods needed to create and retrieve database connection when needed.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • A Offline
          A Offline
          AdrianN17
          wrote on last edited by AdrianN17
          #24

          Sure. It was a mistake using static QSqlDatabase object, because only fail at the deployment.

          Thanks guys.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved