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 Kubuntu + mySQL error

Qt Kubuntu + mySQL error

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 2.2k 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
    ArcNexus
    wrote on last edited by
    #1

    Hi All:

    I'm a beginer in QT c++ and I have an error with mySql connection.

    When I build my first test project for work with mySql in Qt Creator, I have this error:

    /usr/include/qt4/QtSql/qsql_mysql.h:52: error: mysql.h: No such file or directory

    I have instaled all mysql-dev packages in my KUbuntu 12.04 but it return me this error:

    @ mysql.h is in /usr/include/mysql folder but not in /usr/include/qt4/QtSql@

    I have copied this file to qt4 folder but neither works, it returns same error.

    Please help me.

    I use this code in my .cpp for testing:

    @#include "QtSql/QMYSQLDriver"

    if (QSqlDatabase::isDriverAvailable("QMYSQL")) {
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("nombreBD");
    db.setUserName("usuarioBD");
    db.setPassword("claveBD");
    if ( db.open() )
    resultado.setText("Bien, base de datos cargada");
    else {
    QSqlError mensaje = db.lastError();
    resultado.setText(mensaje.text());
    }@

    Thanks for all, and sorry for my bad english.

    When we are one, we win

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hostel
      wrote on last edited by
      #2

      Try this:
      @
      // remove #include "QtSql/QMYSQLDriver"

      include <QSqlDatabase> // this is for database connection

      @

      If this does not help then tell whether you have compiled or installed by a package manager a plugin for MySQL?

      Don't use in code snippets names of databases, passwords and user names for security reasons.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ArcNexus
        wrote on last edited by
        #3

        [quote author="Hostel" date="1338859735"]Try this:
        @
        // remove #include "QtSql/QMYSQLDriver"

        include <QSqlDatabase> // this is for database connection

        @

        If this does not help then tell whether you have compiled or installed by a package manager a plugin for MySQL?

        Don't use in code snippets names of databases, passwords and user names for security reasons.[/quote]

        Thank's, now it work fine :-). But, I need also add this line to my .pro file

        @QT += sql@

        When we are one, we win

        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