Accessing the core and the model from this QML UI project.

This commit is contained in:
2026-03-03 18:58:34 +01:00
parent ed54d5e54e
commit 2ff97c588c
3 changed files with 29 additions and 0 deletions

View File

@ -1,10 +1,31 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <model/generalsortfiltermodel.h>
#include "genericcore.h"
#ifdef QT_DEBUG
#include "utils/messagehandler.h"
#endif
int main(int argc, char* argv[]) {
#ifdef QT_DEBUG
qInstallMessageHandler(consoleHandlerColoredVerboseInDarkTheme);
#endif
QGuiApplication app(argc, argv);
std::unique_ptr<GenericCore> core = std::make_unique<GenericCore>();
std::shared_ptr<GeneralSortFilterModel> mainModel = core->getSortFilterModel();
// qInfo() << "QMLApp Version:" << QMLAPP_VERSION;
qInfo() << "core->getString():" << core->toString();
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty(QStringLiteral("core"), core.get());
engine.rootContext()->setContextProperty(QStringLiteral("mainModel"), mainModel.get());
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
[]() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);