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. Basic qt with mysql?
Forum Updated to NodeBB v4.3 + New Features

Basic qt with mysql?

Scheduled Pinned Locked Moved General and Desktop
17 Posts 4 Posters 8.7k 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.
  • V Offline
    V Offline
    vsorokin
    wrote on last edited by
    #2

    in .pro file you should add
    @QT += sql@

    --
    Vasiliy

    1 Reply Last reply
    0
    • D Offline
      D Offline
      doforumda
      wrote on last edited by
      #3

      now it displays this error
      @
      in function int main(int, char**)
      cannot convert to QSqlDatabase to QSqlDatabase in inititalization main.cpp 9
      @

      1 Reply Last reply
      0
      • ZlatomirZ Offline
        ZlatomirZ Offline
        Zlatomir
        wrote on last edited by
        #4

        That's because you assign QSqlDatabase *defaultDB ( a pointer) with what "addDatabase(...)":http://doc.qt.nokia.com/4.6/qsqldatabase.html#addDatabase returns (a QSqlDatabase, not a pointer to QSqlDatabase)

        https://forum.qt.io/category/41/romanian

        1 Reply Last reply
        0
        • D Offline
          D Offline
          doforumda
          wrote on last edited by
          #5

          so i should use something like this QSqlDatabase defaultDB = QSqlDatabase::addDatabase("QMYSQL");

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DenisKormalev
            wrote on last edited by
            #6

            Yes. And in case of one db without name (i.e. default database) you don't need to provide it to QSqlQuery.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              doforumda
              wrote on last edited by
              #7

              now it displays this error
              @
              in function int main(int, chat**)
              no match for operator! in !db
              candidates are operator!(bool) <built-in>
              @

              1 Reply Last reply
              0
              • ZlatomirZ Offline
                ZlatomirZ Offline
                Zlatomir
                wrote on last edited by
                #8

                You can use "isValid()":http://doc.qt.nokia.com/4.6/qsqldatabase.html#isValid

                https://forum.qt.io/category/41/romanian

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  doforumda
                  wrote on last edited by
                  #9

                  now it is saying
                  @
                  QSqlDatabase: QMysql driver is not loaded
                  QSqlDatabase: available drivers :QSQLITE QSQLITE2
                  @

                  i have installed Mysql driver here "Your text to link here...":http://developer.qt.nokia.com/forums/viewthread/1121/P30/

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DenisKormalev
                    wrote on last edited by
                    #10

                    It says that something is wrong with your mysql plugin. What do you have in your plugins/sqldrivers folder?

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      doforumda
                      wrote on last edited by
                      #11

                      i have 10 different folders and four files. files with names are libqsqlmysql.so, qsqldriverbase.pri, readme, sqldriver.pro

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        doforumda
                        wrote on last edited by
                        #12

                        i also run this code
                        @
                        #include <QCoreApplication>
                        #include <QSqlDatabase>
                        #include <QSqlError>
                        #include <QStringList>
                        #include <QtDebug>

                          int main( int argc, char *argv )
                          {
                          QCoreApplication app( argc, argv );
                          qDebug() << QSqlDatabase::drivers();
                          }
                        

                        @

                        it displays this
                        @
                        ("QSQLITE","QSQLITE2")
                        @

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          DenisKormalev
                          wrote on last edited by
                          #13

                          Not folder with plugin sources, but folder with qt plugin binaries. It is folder named plugins/sqldrivers in root of your Qt folder.

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            doforumda
                            wrote on last edited by
                            #14

                            well i checked this in this path home/qtsdk-2010.05/qt/src/plugins/sqldrivers

                            I have two plugins folders. one in home/qtsdk-2010.05/qt/plugins
                            in this plugin folder i have 11 folders with one named sqldrivers. inside this sqldriver folder i have these 3 files "libqsqlite.so, libqsqlite2.so, libqsqlpsql.so"

                            the other is mentioned above which inside src.

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

                              Put mysql plugin in this folder.

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                doforumda
                                wrote on last edited by
                                #16

                                from which folder i can get mysql plugin and what is the name of that mysql plugin? you mean this one libqsqlmysql.so which is in src/plugins/sqldrivers/mysql folder?

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

                                  yes

                                  1 Reply Last reply
                                  0

                                  • Login

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