Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlQuery not found.
Qt 6.11 is out! See what's new in the release blog

QSqlQuery not found.

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 345 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.
  • T Offline
    T Offline
    TTBlueprints
    wrote on last edited by
    #1

    Hi.

    I am new to C++, and I have started working on a QT Widget project as I have seen people suggest it for making easy Windows applications.

    I want to create a window that shows an SQL database's information on the QT Window. The API suggests using "QSqlQuery", by using #include <QSqlQuery> but I get the error 'QSqlQuery' file not found, and all of the functions for the class are not available because of this.

    Can someone please let me know what needs to be done to remedy this issue? Do I need to install some kind of module for QT Creator in order to get this library of tools to work? Is QT Creator the right program to make this kind of project with?

    I am using QT Creator Community 20.0.0 and can provide any other information required.

    Thank you.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      When you want to use a class you also have to make sure the header and libraries are correctly found and linked in. On every Qt class documentation page you can find what you have to do for this to happen.
      See https://doc.qt.io/qt-6/qsqlquery.html

      Header: #include <QSqlQuery>
      CMake: find_package(Qt6 REQUIRED COMPONENTS Sql)
      target_link_libraries(mytarget PRIVATE Qt6::Sql)
      qmake: QT += sql

      So depending on if you need qmake or cmake you have to add the commands above to your pro-file or CMakeLists.txt

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • T TTBlueprints has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved