QSqlQuery not found.
-
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.
-
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.htmlHeader: #include <QSqlQuery>
CMake: find_package(Qt6 REQUIRED COMPONENTS Sql)
target_link_libraries(mytarget PRIVATE Qt6::Sql)
qmake: QT += sqlSo depending on if you need qmake or cmake you have to add the commands above to your pro-file or CMakeLists.txt
-
T TTBlueprints has marked this topic as solved on