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. qt-cmake: command not found
Forum Updated to NodeBB v4.3 + New Features

qt-cmake: command not found

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
qmysqlqt6cmakemysqlmariadb
17 Posts 4 Posters 3.0k Views
  • 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.
  • M MH24

    @jsulm said in qt-cmake: command not found:

    @MH24 If on Linux simply use cmake instead of qt-cmake

    Turns out I am using Qt 5 and not 6. My mistake.
    However, this has produced a new problem. From here: https://doc.qt.io/qt-5/sql-driver.html#qmysql
    There is no mysql-devel package. I found mysql-client but when I checked /usr/lib/x86_64-linux-gnu there is no libmysqlclient.so.
    If you could kindly guide me on that. Thank you.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @MH24 My Xubuntu 20.04 has libmysqlclient-dev

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    M 1 Reply Last reply
    0
    • jsulmJ jsulm

      @MH24 My Xubuntu 20.04 has libmysqlclient-dev

      M Offline
      M Offline
      MH24
      wrote on last edited by MH24
      #5

      @jsulm said in qt-cmake: command not found:

      @MH24 My Xubuntu 20.04 has libmysqlclient-dev

      Yes I installed it and now I found the libmysqlclient.so in /usr/lib/x86_64-linux-gnu.
      I copied it to /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers
      Thats where the libsqlite.so was found but when I run my code it says:

      QSqlDatabase: QMySQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
      QSqlQuery::exec: database not open
      

      I think I am nearly there and frantically searching old threads but cant put my finger on it. Thank you again for your valuable time.

      qtdiag gave me this:

      Qt 5.15.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.3.0) on "xcb" 
      OS: Ubuntu 22.04.2 LTS [linux version 5.19.0-35-generic]
      
      Architecture: x86_64; features: SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVX2
      
      Environment:
      
      Features: QT_NO_EXCEPTIONS
      
      Library info:
        PrefixPath: /usr
        DocumentationPath: /usr/share/qt5/doc
        HeadersPath: /usr/include/x86_64-linux-gnu/qt5
        LibrariesPath: /usr/lib/x86_64-linux-gnu
        LibraryExecutablesPath: /usr/lib/x86_64-linux-gnu/qt5/libexec
        BinariesPath: /usr/lib/qt5/bin
        PluginsPath: /usr/lib/x86_64-linux-gnu/qt5/plugins
        ImportsPath: /usr/lib/x86_64-linux-gnu/qt5/imports
        Qml2ImportsPath: /usr/lib/x86_64-linux-gnu/qt5/qml
        ArchDataPath: /usr/lib/x86_64-linux-gnu/qt5
        DataPath: /usr/share/qt5
        TranslationsPath: /usr/share/qt5/translations
        ExamplesPath: /usr/lib/x86_64-linux-gnu/qt5/examples
        TestsPath: /usr/tests
        SettingsPath: /etc/xdg
      
      

      I could not find any folder cd $QTDIR/qtbase/src/plugins/sqldrivers.
      sqldrivers folder was in /usr/lib/x86_64-linux-gnu/qt5/plugins/ as I said above.
      When I cd into that and run qmake -- MYSQL_PREFIX=/usr/local as in the documentation I get this:

      Usage: /usr/lib/qt5/bin/qmake [mode] [options] [files]
      
      QMake has two modes, one mode for generating project files based on
      some heuristics, and the other for generating makefiles. Normally you
      shouldn't need to specify a mode, as makefile generation is the default
      mode for qmake, but you may use this to test qmake on an existing project
      
      Mode: ......
      
      jsulmJ 1 Reply Last reply
      0
      • M MH24

        @jsulm said in qt-cmake: command not found:

        @MH24 My Xubuntu 20.04 has libmysqlclient-dev

        Yes I installed it and now I found the libmysqlclient.so in /usr/lib/x86_64-linux-gnu.
        I copied it to /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers
        Thats where the libsqlite.so was found but when I run my code it says:

        QSqlDatabase: QMySQL driver not loaded
        QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
        QSqlQuery::exec: database not open
        

        I think I am nearly there and frantically searching old threads but cant put my finger on it. Thank you again for your valuable time.

        qtdiag gave me this:

        Qt 5.15.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.3.0) on "xcb" 
        OS: Ubuntu 22.04.2 LTS [linux version 5.19.0-35-generic]
        
        Architecture: x86_64; features: SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVX2
        
        Environment:
        
        Features: QT_NO_EXCEPTIONS
        
        Library info:
          PrefixPath: /usr
          DocumentationPath: /usr/share/qt5/doc
          HeadersPath: /usr/include/x86_64-linux-gnu/qt5
          LibrariesPath: /usr/lib/x86_64-linux-gnu
          LibraryExecutablesPath: /usr/lib/x86_64-linux-gnu/qt5/libexec
          BinariesPath: /usr/lib/qt5/bin
          PluginsPath: /usr/lib/x86_64-linux-gnu/qt5/plugins
          ImportsPath: /usr/lib/x86_64-linux-gnu/qt5/imports
          Qml2ImportsPath: /usr/lib/x86_64-linux-gnu/qt5/qml
          ArchDataPath: /usr/lib/x86_64-linux-gnu/qt5
          DataPath: /usr/share/qt5
          TranslationsPath: /usr/share/qt5/translations
          ExamplesPath: /usr/lib/x86_64-linux-gnu/qt5/examples
          TestsPath: /usr/tests
          SettingsPath: /etc/xdg
        
        

        I could not find any folder cd $QTDIR/qtbase/src/plugins/sqldrivers.
        sqldrivers folder was in /usr/lib/x86_64-linux-gnu/qt5/plugins/ as I said above.
        When I cd into that and run qmake -- MYSQL_PREFIX=/usr/local as in the documentation I get this:

        Usage: /usr/lib/qt5/bin/qmake [mode] [options] [files]
        
        QMake has two modes, one mode for generating project files based on
        some heuristics, and the other for generating makefiles. Normally you
        shouldn't need to specify a mode, as makefile generation is the default
        mode for qmake, but you may use this to test qmake on an existing project
        
        Mode: ......
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @MH24 said in qt-cmake: command not found:

        I copied it to /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers

        This is not needed.

        To find out what is wrong set QT_DEBUG_PLUGINS before executing your app and check the output. See https://doc.qt.io/qt-6/debug.html

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply
        0
        • jsulmJ jsulm

          @MH24 said in qt-cmake: command not found:

          I copied it to /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers

          This is not needed.

          To find out what is wrong set QT_DEBUG_PLUGINS before executing your app and check the output. See https://doc.qt.io/qt-6/debug.html

          M Offline
          M Offline
          MH24
          wrote on last edited by
          #7

          @jsulm said in qt-cmake: command not found:

          QT_DEBUG_PLUGINS

          Yes I set it to 1 from 'projects'.
          I got this when I hit ' Start debugging of startup project':

          15:53:54: Starting /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain...
          QSqlDatabase: QMySQL driver not loaded
          QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
          QSqlQuery::exec: database not open
          In Main with ID:
          52428806
          15:53:56: /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain exited with code 0
          
          15:56:25: Starting /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain...
          QSqlDatabase: QMySQL driver not loaded
          QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
          QSqlQuery::exec: database not open
          In Main with ID:
          52428806
          15:56:31: /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain exited with code 0
          
          15:57:18: Starting /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain...
          QSqlDatabase: QMySQL driver not loaded
          QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
          QSqlQuery::exec: database not open
          In Main with ID:
          52428806
          15:57:21: /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain exited with code 0
          
          15:57:44: Debugging /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain ...
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
              "MetaData": {
                  "Keys": [
                      "eglfs"
                  ]
              },
              "archreq": 0,
              "className": "QEglFSIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("eglfs")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
              "MetaData": {
                  "Keys": [
                      "linuxfb"
                  ]
              },
              "archreq": 0,
              "className": "QLinuxFbIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("linuxfb")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
              "MetaData": {
                  "Keys": [
                      "minimal"
                  ]
              },
              "archreq": 0,
              "className": "QMinimalIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("minimal")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
              "MetaData": {
                  "Keys": [
                      "minimalegl"
                  ]
              },
              "archreq": 0,
              "className": "QMinimalEglIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("minimalegl")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
              "MetaData": {
                  "Keys": [
                      "offscreen"
                  ]
              },
              "archreq": 0,
              "className": "QOffscreenIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("offscreen")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
              "MetaData": {
                  "Keys": [
                      "vnc"
                  ]
              },
              "archreq": 0,
              "className": "QVncIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("vnc")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
              "MetaData": {
                  "Keys": [
                      "xcb"
                  ]
              },
              "archreq": 0,
              "className": "QXcbIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("xcb")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/platforms" ...
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
          loaded library "Xcursor"
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/libqgtk3.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/libqgtk3.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
              "MetaData": {
                  "Keys": [
                      "gtk3"
                  ]
              },
              "archreq": 0,
              "className": "QGtk3ThemePlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("gtk3")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/platformthemes" ...
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/libqgtk3.so"
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1",
              "MetaData": {
                  "Keys": [
                      "compose",
                      "xim"
                  ]
              },
              "archreq": 0,
              "className": "QComposePlatformInputContextPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("compose", "xim")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1",
              "MetaData": {
                  "Keys": [
                      "ibus"
                  ]
              },
              "archreq": 0,
              "className": "QIbusPlatformInputContextPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("ibus")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/platforminputcontexts" ...
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/styles" ...
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/styles" ...
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/iconengines" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/iconengines/libqsvgicon.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/iconengines/libqsvgicon.so, metadata=
          {
              "IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "svg",
                      "svgz",
                      "svg.gz"
                  ]
              },
              "archreq": 0,
              "className": "QSvgIconPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("svg", "svgz", "svg.gz")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/iconengines" ...
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqgif.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqgif.so, metadata=
          {
              "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "gif"
                  ],
                  "MimeTypes": [
                      "image/gif"
                  ]
              },
              "archreq": 0,
              "className": "QGifPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("gif")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqico.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqico.so, metadata=
          {
              "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "ico",
                      "cur"
                  ],
                  "MimeTypes": [
                      "image/vnd.microsoft.icon",
                      "image/vnd.microsoft.icon"
                  ]
              },
              "archreq": 0,
              "className": "QICOPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("ico", "cur")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqjpeg.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqjpeg.so, metadata=
          {
              "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "jpg",
                      "jpeg"
                  ],
                  "MimeTypes": [
                      "image/jpeg",
                      "image/jpeg"
                  ]
              },
              "archreq": 0,
              "className": "QJpegPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("jpg", "jpeg")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqsvg.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqsvg.so, metadata=
          {
              "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "svg",
                      "svgz"
                  ],
                  "MimeTypes": [
                      "image/svg+xml",
                      "image/svg+xml-compressed"
                  ]
              },
              "archreq": 0,
              "className": "QSvgPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("svg", "svgz")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/imageformats" ...
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqgif.so"
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqico.so"
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqjpeg.so"
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqsvg.so"
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so"
          "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                   not a plugin
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
          {
              "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "QSQLITE"
                  ]
              },
              "archreq": 0,
              "className": "QSQLiteDriverPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("QSQLITE")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so, metadata=
          {
              "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
              "MetaData": {
                  "Keys": [
                      "QMYSQL3",
                      "QMYSQL",
                      "QMARIADB"
                  ]
              },
              "archreq": 0,
              "className": "QMYSQLDriverPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/sqldrivers" ...
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
          QSqlDatabase: QMySQL driver not loaded
          QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
          QSqlQuery::exec: database not open
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations" ...
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-egl-integration.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-egl-integration.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5",
              "MetaData": {
                  "Keys": [
                      "xcb_egl"
                  ]
              },
              "archreq": 0,
              "className": "QXcbEglIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("xcb_egl")
          QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"
          Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so, metadata=
          {
              "IID": "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5",
              "MetaData": {
                  "Keys": [
                      "xcb_glx"
                  ]
              },
              "archreq": 0,
              "className": "QXcbGlxIntegrationPlugin",
              "debug": false,
              "version": 331520
          }
          
          
          Got keys from plugin meta data ("xcb_glx")
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/xcbglintegrations" ...
          loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/accessible" ...
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/accessible" ...
          In Main with ID:
          52428806
          QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/accessiblebridge" ...
          QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/accessiblebridge" ...
          

          Completely lost here. Why doesn't the qmake command work for me as stated in docs?

          JonBJ 1 Reply Last reply
          0
          • M MH24

            @jsulm said in qt-cmake: command not found:

            QT_DEBUG_PLUGINS

            Yes I set it to 1 from 'projects'.
            I got this when I hit ' Start debugging of startup project':

            15:53:54: Starting /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain...
            QSqlDatabase: QMySQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
            QSqlQuery::exec: database not open
            In Main with ID:
            52428806
            15:53:56: /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain exited with code 0
            
            15:56:25: Starting /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain...
            QSqlDatabase: QMySQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
            QSqlQuery::exec: database not open
            In Main with ID:
            52428806
            15:56:31: /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain exited with code 0
            
            15:57:18: Starting /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain...
            QSqlDatabase: QMySQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
            QSqlQuery::exec: database not open
            In Main with ID:
            52428806
            15:57:21: /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain exited with code 0
            
            15:57:44: Debugging /home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/UniAppMain ...
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                    "Keys": [
                        "eglfs"
                    ]
                },
                "archreq": 0,
                "className": "QEglFSIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("eglfs")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                    "Keys": [
                        "linuxfb"
                    ]
                },
                "archreq": 0,
                "className": "QLinuxFbIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("linuxfb")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                    "Keys": [
                        "minimal"
                    ]
                },
                "archreq": 0,
                "className": "QMinimalIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("minimal")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                    "Keys": [
                        "minimalegl"
                    ]
                },
                "archreq": 0,
                "className": "QMinimalEglIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("minimalegl")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                    "Keys": [
                        "offscreen"
                    ]
                },
                "archreq": 0,
                "className": "QOffscreenIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("offscreen")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                    "Keys": [
                        "vnc"
                    ]
                },
                "archreq": 0,
                "className": "QVncIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("vnc")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                "MetaData": {
                    "Keys": [
                        "xcb"
                    ]
                },
                "archreq": 0,
                "className": "QXcbIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("xcb")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/platforms" ...
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
            loaded library "Xcursor"
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/libqgtk3.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/libqgtk3.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
                "MetaData": {
                    "Keys": [
                        "gtk3"
                    ]
                },
                "archreq": 0,
                "className": "QGtk3ThemePlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("gtk3")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/platformthemes" ...
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/libqgtk3.so"
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1",
                "MetaData": {
                    "Keys": [
                        "compose",
                        "xim"
                    ]
                },
                "archreq": 0,
                "className": "QComposePlatformInputContextPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("compose", "xim")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1",
                "MetaData": {
                    "Keys": [
                        "ibus"
                    ]
                },
                "archreq": 0,
                "className": "QIbusPlatformInputContextPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("ibus")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/platforminputcontexts" ...
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/styles" ...
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/styles" ...
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/iconengines" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/iconengines/libqsvgicon.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/iconengines/libqsvgicon.so, metadata=
            {
                "IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "svg",
                        "svgz",
                        "svg.gz"
                    ]
                },
                "archreq": 0,
                "className": "QSvgIconPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("svg", "svgz", "svg.gz")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/iconengines" ...
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqgif.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqgif.so, metadata=
            {
                "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "gif"
                    ],
                    "MimeTypes": [
                        "image/gif"
                    ]
                },
                "archreq": 0,
                "className": "QGifPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("gif")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqico.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqico.so, metadata=
            {
                "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "ico",
                        "cur"
                    ],
                    "MimeTypes": [
                        "image/vnd.microsoft.icon",
                        "image/vnd.microsoft.icon"
                    ]
                },
                "archreq": 0,
                "className": "QICOPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("ico", "cur")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqjpeg.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqjpeg.so, metadata=
            {
                "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "jpg",
                        "jpeg"
                    ],
                    "MimeTypes": [
                        "image/jpeg",
                        "image/jpeg"
                    ]
                },
                "archreq": 0,
                "className": "QJpegPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("jpg", "jpeg")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqsvg.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqsvg.so, metadata=
            {
                "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "svg",
                        "svgz"
                    ],
                    "MimeTypes": [
                        "image/svg+xml",
                        "image/svg+xml-compressed"
                    ]
                },
                "archreq": 0,
                "className": "QSvgPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("svg", "svgz")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/imageformats" ...
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqgif.so"
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqico.so"
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqjpeg.so"
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqsvg.so"
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so"
            "Failed to extract plugin meta data from '/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libmysqlclient.so'" 
                     not a plugin
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
            {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "QSQLITE"
                    ]
                },
                "archreq": 0,
                "className": "QSQLiteDriverPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("QSQLITE")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so, metadata=
            {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "QMYSQL3",
                        "QMYSQL",
                        "QMARIADB"
                    ]
                },
                "archreq": 0,
                "className": "QMYSQLDriverPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/sqldrivers" ...
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so"
            QSqlDatabase: QMySQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3
            QSqlQuery::exec: database not open
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations" ...
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-egl-integration.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-egl-integration.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5",
                "MetaData": {
                    "Keys": [
                        "xcb_egl"
                    ]
                },
                "archreq": 0,
                "className": "QXcbEglIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("xcb_egl")
            QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"
            Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so, metadata=
            {
                "IID": "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5",
                "MetaData": {
                    "Keys": [
                        "xcb_glx"
                    ]
                },
                "archreq": 0,
                "className": "QXcbGlxIntegrationPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("xcb_glx")
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/xcbglintegrations" ...
            loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/accessible" ...
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/accessible" ...
            In Main with ID:
            52428806
            QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/accessiblebridge" ...
            QFactoryLoader::QFactoryLoader() checking directory path "/home/developer/Qt-Work/build-UniAppMain-Desktop-Debug/accessiblebridge" ...
            

            Completely lost here. Why doesn't the qmake command work for me as stated in docs?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #8

            @MH24
            I don't know what qmake has to do with anything when you are showing your executable built and running.

            You do not show your addDatabase() call from your code so we can see you trying to use the MySQL driver. But:

            QSqlDatabase: QMySQL driver not loaded

            QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3

            So did you at least try with QMYSQL not QMySQL?

            M 1 Reply Last reply
            2
            • JonBJ JonB

              @MH24
              I don't know what qmake has to do with anything when you are showing your executable built and running.

              You do not show your addDatabase() call from your code so we can see you trying to use the MySQL driver. But:

              QSqlDatabase: QMySQL driver not loaded

              QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3

              So did you at least try with QMYSQL not QMySQL?

              M Offline
              M Offline
              MH24
              wrote on last edited by MH24
              #9

              @JonB said in qt-cmake: command not found:

              @MH24
              I don't know what qmake has to do with anything when you are showing your executable built and running.

              You do not show your addDatabase() call from your code so we can see you trying to use the MySQL driver. But:

              QSqlDatabase: QMySQL driver not loaded

              QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3

              So did you at least try with QMYSQL not QMySQL?

              Well, qmake was mentioned in the official docs for Qt5 driver installation.

              Yes, my mistake was that after I had moved the drivers' shared objects to the sqldriver folder I had written QMySQL instead of QMYSQL in my code copied from official docs. However, my database is not open so I dont know whether the driver works

              This is my code:

              #include <QSqlDatabase>
              #include <QSql>
              #include <QSqlQueryModel>
              #include <QSqlQuery>
              #include <QSqlError>
              #include <QSqlDriver>
              
              //class declaration, rest of the functions etc
              QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
              db.setHostName("localhost");
              db.setDatabaseName("uniapp");
              db.setUserName("root");
              db.setPassword("******"); 
              bool ok = db.open();
              
              QSqlQuery query;
              query.exec("INSERT INTO employee (id, name)"
                         "VALUES (1001, 'XYZ')");
              

              This gives QSqlQuery::exec: database not open.
              If I remove the lines of query from the code there is no error even if I give wrong password etc.
              Apologies if this thread has diverted, but I need to be sure Qt is connecting to my MySQL database.
              I have the server running on my machine with mysql -u root -p and SHOW DATABASES; shows my database.

              JonBJ 1 Reply Last reply
              0
              • M MH24

                @JonB said in qt-cmake: command not found:

                @MH24
                I don't know what qmake has to do with anything when you are showing your executable built and running.

                You do not show your addDatabase() call from your code so we can see you trying to use the MySQL driver. But:

                QSqlDatabase: QMySQL driver not loaded

                QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3

                So did you at least try with QMYSQL not QMySQL?

                Well, qmake was mentioned in the official docs for Qt5 driver installation.

                Yes, my mistake was that after I had moved the drivers' shared objects to the sqldriver folder I had written QMySQL instead of QMYSQL in my code copied from official docs. However, my database is not open so I dont know whether the driver works

                This is my code:

                #include <QSqlDatabase>
                #include <QSql>
                #include <QSqlQueryModel>
                #include <QSqlQuery>
                #include <QSqlError>
                #include <QSqlDriver>
                
                //class declaration, rest of the functions etc
                QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
                db.setHostName("localhost");
                db.setDatabaseName("uniapp");
                db.setUserName("root");
                db.setPassword("******"); 
                bool ok = db.open();
                
                QSqlQuery query;
                query.exec("INSERT INTO employee (id, name)"
                           "VALUES (1001, 'XYZ')");
                

                This gives QSqlQuery::exec: database not open.
                If I remove the lines of query from the code there is no error even if I give wrong password etc.
                Apologies if this thread has diverted, but I need to be sure Qt is connecting to my MySQL database.
                I have the server running on my machine with mysql -u root -p and SHOW DATABASES; shows my database.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #10

                @MH24 said in qt-cmake: command not found:

                bool ok = db.open();

                This gives QSqlQuery::exec: database not open.

                You are supposed to test the ok result, else what is the point of assigning it?

                Presumably it is returning false, hence the error message. In which case what does db.lastError() return, as per the documentation?

                M 1 Reply Last reply
                0
                • JonBJ JonB

                  @MH24 said in qt-cmake: command not found:

                  bool ok = db.open();

                  This gives QSqlQuery::exec: database not open.

                  You are supposed to test the ok result, else what is the point of assigning it?

                  Presumably it is returning false, hence the error message. In which case what does db.lastError() return, as per the documentation?

                  M Offline
                  M Offline
                  MH24
                  wrote on last edited by
                  #11

                  @JonB said in qt-cmake: command not found:

                  @MH24 said in qt-cmake: command not found:

                  bool ok = db.open();

                  This gives QSqlQuery::exec: database not open.

                  You are supposed to test the ok result, else what is the point of assigning it?

                  Presumably it is returning false, hence the error message. In which case what does db.lastError() return, as per the documentation?

                  It returns this:
                  QSqlError("1698", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost'")

                  JonBJ Christian EhrlicherC 2 Replies Last reply
                  0
                  • M MH24

                    @JonB said in qt-cmake: command not found:

                    @MH24 said in qt-cmake: command not found:

                    bool ok = db.open();

                    This gives QSqlQuery::exec: database not open.

                    You are supposed to test the ok result, else what is the point of assigning it?

                    Presumably it is returning false, hence the error message. In which case what does db.lastError() return, as per the documentation?

                    It returns this:
                    QSqlError("1698", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost'")

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #12

                    @MH24
                    So that is your answer. I think that indicates the QMYSQL driver from Qt is working OK. I am also guessing this is not an incorrect password issue, I assume that would give a different message (though I cannot be sure).

                    You might try a database other than uniapp, such as mysql or information_schema, to see whether that alters the situation.

                    M 1 Reply Last reply
                    0
                    • M MH24

                      @JonB said in qt-cmake: command not found:

                      @MH24 said in qt-cmake: command not found:

                      bool ok = db.open();

                      This gives QSqlQuery::exec: database not open.

                      You are supposed to test the ok result, else what is the point of assigning it?

                      Presumably it is returning false, hence the error message. In which case what does db.lastError() return, as per the documentation?

                      It returns this:
                      QSqlError("1698", "QMYSQL: Unable to connect", "Access denied for user 'root'@'localhost'")

                      Christian EhrlicherC Online
                      Christian EhrlicherC Online
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      @MH24 said in qt-cmake: command not found:

                      Access denied for user 'root'@'localhost'

                      Very obvoius where the problem is - the user root@localhost has no access rights to this database (and imo never should have access)

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      2
                      • JonBJ JonB

                        @MH24
                        So that is your answer. I think that indicates the QMYSQL driver from Qt is working OK. I am also guessing this is not an incorrect password issue, I assume that would give a different message (though I cannot be sure).

                        You might try a database other than uniapp, such as mysql or information_schema, to see whether that alters the situation.

                        M Offline
                        M Offline
                        MH24
                        wrote on last edited by
                        #14

                        @JonB
                        I tried using different database but same error. I tried granting privileges to the database using
                        grant all privileges on user_database.* to user_user@'localhost' ; grant all privileges on user_database.* to user_user@'%' ;

                        but to no avail.

                        JonBJ 1 Reply Last reply
                        0
                        • M MH24

                          @JonB
                          I tried using different database but same error. I tried granting privileges to the database using
                          grant all privileges on user_database.* to user_user@'localhost' ; grant all privileges on user_database.* to user_user@'%' ;

                          but to no avail.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #15

                          @MH24
                          This is beyond my ken for MySQL. I have used the MYSQL connector under Ubuntu and it all worked for me, that's all I can say.

                          M 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @MH24
                            This is beyond my ken for MySQL. I have used the MYSQL connector under Ubuntu and it all worked for me, that's all I can say.

                            M Offline
                            M Offline
                            MH24
                            wrote on last edited by
                            #16

                            @JonB
                            Created a new user. Gave it all privileges. Data inserted. Works like a charm.
                            root@localhost doesn't work. new_user@localhost does. Don't know why.

                            Thank you for your help and @jsulm and @Christian-Ehrlicher.

                            JonBJ 1 Reply Last reply
                            0
                            • M MH24

                              @JonB
                              Created a new user. Gave it all privileges. Data inserted. Works like a charm.
                              root@localhost doesn't work. new_user@localhost does. Don't know why.

                              Thank you for your help and @jsulm and @Christian-Ehrlicher.

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by
                              #17

                              @MH24
                              It vaguely, vaguely rings a bell that you have to do something special about root, possibly to do with how MySQL gets installed initially. Lots of hits for Googling mysql root localhost permission. I may have done the stuff mentioned in https://stackoverflow.com/a/46908573 in the past. (Be careful you don't lock yourself out, however!)

                              But in any case what you have done now is better, as @Christian-Ehrlicher said you should not be using root user for your application.

                              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