Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QMYSQLDriver
Forum Updated to NodeBB v4.3 + New Features

Problem with QMYSQLDriver

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 3 Posters 5.9k Views 3 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.
  • D Offline
    D Offline
    DoubleC122
    wrote on last edited by
    #13

    Yes indeed, I followed that example but for QMYSQL. I stopped right after instantiating the drv pointer because it was not recognizing the QMYSQLDriver.

    mrjjM 1 Reply Last reply
    0
    • D DoubleC122

      Yes indeed, I followed that example but for QMYSQL. I stopped right after instantiating the drv pointer because it was not recognizing the QMYSQLDriver.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #14

      @DoubleC122
      and you changed the path to points to the mysql. cpp file ?
      (the class is defined there)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DoubleC122
        wrote on last edited by
        #15

        Yes, I changed everything there to go as it should. But apparently it didnt. I included just like this: #include "/home/catalin/Qt/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp". And Qt recognizes it. I also checked if there was actually that .cpp file there just to be sure, even if it is redundant to do so.

        mrjjM 1 Reply Last reply
        0
        • D DoubleC122

          Yes, I changed everything there to go as it should. But apparently it didnt. I included just like this: #include "/home/catalin/Qt/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp". And Qt recognizes it. I also checked if there was actually that .cpp file there just to be sure, even if it is redundant to do so.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #16

          @DoubleC122
          and this .cpp should include the .h file and the object should be known. hmm.
          Its not inside namespace or anything that would prevent it from knowing type ?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DoubleC122
            wrote on last edited by DoubleC122
            #17

            Not really, I tried using that even in a simple non Qt project, to see if at least that would do, but it didn't. For instance, in a simple blank project, I include whatever I need, plus the mysql connector header files and the path to the .cpp. Then, in main, I have just these lines:

            sql::Driver *driver;
            sql::Connection *con;
            
            driver = get_driver_instance();
            con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
            
            QMYSQLDriver *drv = new QMYSQLDriver(con);
            

            And it says that #include <QtSql/private/qsqldriver_p.h> and #include <QtSql/private/qsqlresult_p.h> 'no such file or directory'. These are included in the qsql_mysql.cpp file. I certainly have those headers, since I looked a thousand times for them. If I try to include them 'manually', pretty much as I did for the qsql_mysql.cpp, it works, but I don't feel like it's a good idea also because then it moves on the other headers inside those I included and says the same error. Maybe the headers in qsql_mysql.cpp point somewhere else than where I looked for, I really have no idea.

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #18

              Hi
              I wonder if you need something like (in .pro file)
              QT += gui-private
              as we do for other private headers.
              (looking for right name)

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DoubleC122
                wrote on last edited by DoubleC122
                #19

                @mrjj said in Problem with QMYSQLDriver:

                gui-private

                Unfortunately it doesnt change anything. Actually, I saw something else. If I just include the .cpp file without writing anything else, it shows me the header errors. Before, it showed me that the QMYSQLDriver was not declared in this scope, now if I just include the .cpp file, it shows me this error, which it didn't before.

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

                  Hi,

                  That would be sql-private. But from a quick look the plugin headers are not exported.

                  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
                  1
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #21

                    So its not really possible to use a stand alone driver as the helps shows ?
                    or it does only apply to the QPSQLDriver ?

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DoubleC122
                      wrote on last edited by
                      #22

                      Frankly now that I spent so much time on this error, I think I could use the normal QSqlDatabase class without using the connector from mysql. From what I saw it's similar to the QMYSQLDriver in the sense that I need to specify what database I want to use just like what I wanted to do before, but instead I don't use any other non qt driver in between, and of course mysql is in the list of supported connection databases so it's really good.

                      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