Pass db instance to models. Pass models to QML.

This commit is contained in:
2020-06-06 22:01:45 -04:00
parent 163441c4ef
commit eda53f9663
5 changed files with 11 additions and 4 deletions

View File

@@ -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()) {