Pass db instance to models. Pass models to QML.
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
#include <QDebug>
|
||||
#include <QSqlQuery>
|
||||
#include <QQmlContext>
|
||||
#include "db/sqlvehicle.h"
|
||||
#include "db/sqlservicerecord.h"
|
||||
|
||||
Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -67,8 +69,13 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
return -2;
|
||||
}
|
||||
|
||||
SqlVehicle vehicles(nullptr, db);
|
||||
SqlServiceRecord records(nullptr, db);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("appAboutData"), QVariant::fromValue(aboutData));
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("vehicleModel"), &vehicles);
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("recordModel"), &records);
|
||||
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
|
||||
|
||||
if (engine.rootObjects().isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user