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

Database class

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 6.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.
  • ? Offline
    ? Offline
    A Former User
    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.

    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
      • ? Offline
        ? Offline
        A Former User
        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

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

          ok i figured it out, I needed to

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

          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
            • ? Offline
              ? Offline
              A Former User
              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

              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
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

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

                  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