rename db column to not conflict with qml. Make sure to call select on first load of table models to poulate.
Make model classes have some functions accessible from qml. Add custom model method that allows QML to easily add new items. Add Card layout that contains data from db.
This commit is contained in:
@@ -58,7 +58,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
QFile(db.databaseName()).open(QIODevice::ReadWrite);
|
||||
//Create table structure
|
||||
db.open();
|
||||
db.exec("CREATE TABLE vehicles (id INTEGER PRIMARY KEY, name TEXT, maker TEXT, model TEXT, year INTEGER, image TEXT, vin TEXT);");
|
||||
db.exec("CREATE TABLE vehicles (id INTEGER PRIMARY KEY, name TEXT, maker TEXT, vmodel TEXT, year INTEGER, image TEXT, vin TEXT);");
|
||||
db.exec("CREATE TABLE records (id INTEGER PRIMARY KEY, servicetype TEXT, date INTEGER, miles INTEGER, notes TEXT);");
|
||||
db.commit();
|
||||
db.close();
|
||||
@@ -72,6 +72,8 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
|
||||
SqlVehicle vehicles(nullptr, db);
|
||||
SqlServiceRecord records(nullptr, db);
|
||||
vehicles.select();
|
||||
records.select();
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("appAboutData"), QVariant::fromValue(aboutData));
|
||||
|
||||
Reference in New Issue
Block a user