Results 1 to 2 of 2

Thread: qt connect with mysql in fedora

  1. #1
    Join Date
    Mar 2011
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qt connect with mysql in fedora

    hi am trying to connect mysql with qt....using following code :
    #include"QApplication"
    #include <QSqlDatabase>
    bool createConnection()
    {
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("mozart.konkordia.edu");
    db.setDatabaseName("musicdb");
    db.setUserName("gbatstone");
    db.setPassword("T17aV44");
    if (!db.open()) {
    QMessageBox::critical(0, QObject::tr("Database Error"),
    db.lastError().text());
    return false;
    }
    return true;
    }


    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    if (!createConnection())
    cout<<"error";
    return app.exec();
    }

    but it gives the following error
    fatal error: QSqlDatabase: No such file or directory
    compilation terminated.


    how to solve it.....
    plz help

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qt connect with mysql in fedora

    specify the following in your .pro file:

    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Mysql unknown database, QMYSQL unable to connect
    By lixo1 in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2010, 21:39
  2. Qt connect different MySQL
    By weixj2003ld in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2009, 08:35
  3. How to connect MySQL with QT
    By diego in forum Qt Programming
    Replies: 0
    Last Post: 27th May 2009, 05:34
  4. Qt and mysql on fedora 9
    By cbarmpar in forum Qt Programming
    Replies: 5
    Last Post: 4th September 2008, 19:57
  5. VS2005+Qt4.2.2:Get a Mysql connect error.HELP!!
    By fengtian.we in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2007, 12:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.