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. [SOLVED] <QSqlQuery> vs <QtSql/QSqlQuery>
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] <QSqlQuery> vs <QtSql/QSqlQuery>

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.9k 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
    Resurrection
    wrote on last edited by
    #1

    Solved: The qmake module include must be present in all projects using it even indirectly.

    I was used to add modules to qmake:

    @
    QT += sql
    @

    and then including the classes as:

    @
    #include <QSqlQuery>
    @

    however recently in my plugins/libraries based project I can compile the plugin just fine with the above but when compiling the whole project I get this error:

    @
    QSqlQuery: No such file or directory
    @

    Oddly simply replacing the include with:

    @
    #include <QtSql/QSqlQuery>
    @

    works fine. Why is that? Thx.

    Note: I am using Qt 5.3 and the class header that uses this include is located in a shared library so the class is being exported with Q_DECL_EXPORT if that is of any significance.

    Secrets are power.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbnoimi
      wrote on last edited by
      #2

      AFAIK there is no difference but try to use the following instead:
      [code]#include <QtSql>[/code]

      I usually use it for accessing all SQL classes

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What do you mean by all project vs plugin ?

        On a side note, using module include is a bad habit, while it's ok for rapid prototyping, it should be avoided as it pulls in everything from the module and thus slows down the whole compilation process.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

          2mbnoimi: All sql family includes do not work when used plainly without the qtsql/ (nor does whole module) directory specified with the same error as in OP.

          2SGaist: I have a subdirs project with 2 apps, 3 shared libraries and several dynamic plugins. The problem occurs with one of the libraries. When I compile it on its own (right-click in Creator -> Build/Rebuild) it compiles fine. But when I build one of the apps using it (which also builds the linked libraries) it gives me the error above.

          Secrets are power.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vezprog
            wrote on last edited by
            #5

            Does each of the sub projects that use the SQL plugin have QT += sql in their .pro files?

            When you have a sub project that is a shared library, the shared library requires the Qt module in the .pro as well as the project including files located in the shared library.

            I have had to do this before, try adding QT += sql in the .pro file of the app including files from the shared library.

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

              2devz43: Thanks, this solved the problem!

              Secrets are power.

              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