Results 1 to 9 of 9

Thread: what should i include to work with QSqlDatabase?

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question what should i include to work with QSqlDatabase?

    hello,
    i want to work with QSqlDatabase and QSqlQuery so
    i included the following file
    #include <QtSql>
    but i get a message say :
    Can not open include file :QtSql no such file or directory
    what is wrong?

  2. #2
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: what should i include to work with QSqlDatabase?

    Hi

    you should

    Qt Code:
    1. #include <QSqlDatabase>
    2. #include <QSqlQuery>
    3. #include <QSqlError>
    To copy to clipboard, switch view to plain text mode 

    1st one being for database objects
    2nd for queries
    3rd for meaningful output for any error

    HTH,
    Pedro Doria Meunier

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: what should i include to work with QSqlDatabase?

    Only QtCore and QtGui modules are enabled by default. To add suitable include paths and to link against QtSql module, add this line to your qmake .pro file:
    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: what should i include to work with QSqlDatabase?

    i am using visual studio 2005 and there is no .pro file!!!!
    Last edited by mismael85; 6th March 2008 at 16:55.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: what should i include to work with QSqlDatabase?

    Quote Originally Posted by mismael85 View Post
    i am using visual studio 2005 and there i no .pro file!!!!
    That's a pity. Nobody else can build your project with any other compiler then. Because of that, it is ALWAYS a good idea to maintain a qmake .pro file even if you used this or that IDE.

    Provided that you're using the Visual Studio integration, you can open context menu over the project item in solution explorer. There's a menu item to choose Qt modules.
    J-P Nurmi

  6. The following user says thank you to jpn for this useful post:

    mismael85 (6th March 2008)

  7. #6
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: what should i include to work with QSqlDatabase?

    i used MinGw with a static version of Qt and i added
    Qt += sql
    to the *.pro file
    and it is also say that there is no such file or directory!!!

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: what should i include to work with QSqlDatabase?

    The variable name is QT, not Qt.
    J-P Nurmi

  9. #8
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: what should i include to work with QSqlDatabase?

    thank you for your help .
    for visual studio i did just as you said and it worked fine.
    and for Mingw32-make
    i added Qt += sql but it was wrong
    because *.pro file is case sensitive and it must be
    QT += sql
    when i did that every thing worked fine.
    thank you again.

  10. #9
    Join Date
    Dec 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: what should i include to work with QSqlDatabase?

    Thanks all

Similar Threads

  1. Error: Using Multiple files
    By 3nc31 in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 09:23
  2. Client/Server doesn't work
    By mattia in forum Newbie
    Replies: 2
    Last Post: 1st November 2007, 13:31
  3. setMouseTracking() doesn't work.
    By luffy27 in forum Qt Programming
    Replies: 13
    Last Post: 27th April 2007, 18:16
  4. Can't create an object : initialisation problem ?
    By Nyphel in forum Qt Programming
    Replies: 5
    Last Post: 12th March 2007, 09:07
  5. use button from another Window
    By raphaelf in forum Qt Programming
    Replies: 11
    Last Post: 2nd March 2006, 20:31

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.