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. MySQL with QT
Qt 6.11 is out! See what's new in the release blog

MySQL with QT

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 6.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi guys,

    I'm after a little support in connecting QT up to a MySQL database. I am going to need my application to contact both a remote and local database.

    I have done some searching online however it all seems a little old with many results being from back in the days of QT3 which are of course dead now.

    I do not want to use any crazy C Connector ports from C as these seem to be proving more trouble than they are worth. I am assuming however that both MySQL and QT talk the same talk on some form of ODBC connection.

    If somebody could please help me get started with this, nothing fancy just connections and standard SQL Queries, no stored procedures or anything fancy like that.

    Thanks
    Andrew

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tbscope
      wrote on last edited by
      #2

      Did you already read the documentation?
      http://doc.qt.nokia.com/4.7/qt-sql.html

      If so, can you be more specific with your question?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        You must compile Qt with MySql support and than follow the Qt documentation.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          [quote author="Luca" date="1296632628"]You must compile Qt with MySql support and than follow the Qt documentation.[/quote]

          The SQL plugins can be added later on, no need to completely rebuild a binary installation for Qt.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Thank you tbscope - I was looking for a specific QMySQL class like they have a QSQLLite class. However I notice the pages you gave me include a list of supported drivers.

            Thank You (& forgive my stupidity :-P)
            Andrew

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Oh nope...Just looking now it says the MySQL driver is supported by default and it seems silly ridiculous to get it on the system having to install lots of programs cluttering up my drives.

              Does anybody have a "pre-built" MySQL5.0 or 5.1 driver already built?

              Thanks
              Andrew

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                If you want to use the Qt database driver for MYSQL, I guess all you have to is something like this:

                @
                QSqlDatabase myDb = QSqlDatabase::addDatabase("QMYSQL","DEFAULT");
                myDb.setDatabaseName( [add your file name with path here] );
                if(!myDb.open())
                {
                ... your code
                }
                @

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  This what I'm currently getting running that, from my Application Output;

                  @Starting D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe...
                  QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
                  D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe exited with code -1073741819@

                  And when I run the ODBC driver I just get;

                  @Starting D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe...
                  D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe exited with code -1073741819@

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    Never mind, all sorted.

                    Problems were occuring as I was using Windows Powershell to try and build the driver but actually there was a QT Command Prompt which did the job lovely.

                    Thanks Guys
                    Andrew

                    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