I have a SQLite database for my Qt application. I suppose it would be logical to add the database as a resource.
I cannot get my application to compile with an embedded resource.
connection.h
#ifndef CONNECTION_H #define CONNECTION_H #include <QMessageBox> #include <QSqlDatabase> #include <QSqlError> #include <QSqlQuery> static bool createConnection() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(":/data/ShippingData.db3"); if (!db.open()) { QMessageBox::critical(0, QObject::tr("Database Error"), db.lastError().text()); return false; } return true; } #endif // CONNECTION_H
assets.qrc
<RCC> <qresource prefix="/data"> <file>ShippingData.db3</file> </qresource> </RCC>
My sqlite database right now looks like
app.pro file.h file.cpp data/ShippingData.db3
Build Error (from Qt Creator)
No rule to make target `../TimePlotter/Shipping.db3', needed by `debug/qrc_assets.cpp'. Stop.
I tried to change the layout of the resource, because the compiler from the message does not enter the data / folder folder where the database is located. I get exactly the same build problem with this resource file
<RCC> <qresource> <file>data/ShippingData.db3</file> </qresource> </RCC>
TimePlotter.pro
#-------------------------------------------------
c ++ sqlite qt embedded-resource
Carl Seech
source share