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. Database class

Database class

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 4.3k 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.
  • R Offline
    R Offline
    ryadav
    wrote on last edited by
    #1

    Hi I am trying to use QSqlDatabase, but I am getting build errors and QTCreator doesn't seem to know that QSqlDatabase exists? The IDE is not even auto-completing my typing, etc.

    Running build steps for project app13_sqlite3...
    Configuration unchanged, skipping qmake step.
    Starting: "/usr/bin/make" -w
    make: Entering directory `/home/yadav/dev/cpp/QT_Samples/app13_sqlite3-build-desktop'
    g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../app13_sqlite3 -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I../app13_sqlite3 -I. -o dialog.o ../app13_sqlite3/dialog.cpp
    ../app13_sqlite3/dialog.cpp:4: fatal error: QSqlDatabase: No such file or directory
    compilation terminated.

    Kind Regards,
    Rajinder Yadav

    SafetyNet Test Driven Development
    http://safetynet.devmentor.org

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

      Try to add
      @
      QT += sql
      @
      to your project file

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ryadav
        wrote on last edited by
        #3

        still getting the same error, btw where do i add that? to the project setting -> build steps -> additional arguments ??

        also I can't even navigate to QSqlDatabase.h ? using follow symbol under cursor from the IDE, is there something wrong. should this not work with a default SDK install

        Kind Regards,
        Rajinder Yadav

        SafetyNet Test Driven Development
        http://safetynet.devmentor.org

        1 Reply Last reply
        0
        • R Offline
          R Offline
          ryadav
          wrote on last edited by
          #4

          ok i figured it out, I needed to

          #include <QtSql/QSqlDatabase>
          rather than
          #include <QSqlDatabase>

          Kind Regards,
          Rajinder Yadav

          SafetyNet Test Driven Development
          http://safetynet.devmentor.org

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

            You have .pro file in your project tree. Just add stuff I've said you there and all will be ok.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              ryadav
              wrote on last edited by
              #6

              thanks again, that helped me figure out where to also add the linker stuff so my exe would run without an error

              LIBS += -lsqlite3

              Kind Regards,
              Rajinder Yadav

              SafetyNet Test Driven Development
              http://safetynet.devmentor.org

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                You don't need to add that lib. It is already linked against the Qt SQLite plugin.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  ryadav
                  wrote on last edited by
                  #8

                  Andre thanks, didn't know that, removed the explicit linkage.

                  Kind Regards,
                  Rajinder Yadav

                  SafetyNet Test Driven Development
                  http://safetynet.devmentor.org

                  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