-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (38 loc) · 1.44 KB
/
Copy pathmain.cpp
File metadata and controls
48 lines (38 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickStyle>
#include "DatabaseManager.h"
#include "LibraryModel.h"
#include "SearchModel.h"
int main(int argc, char *argv[])
{
// Force non-native style
qputenv("QT_QUICK_CONTROLS_STYLE", "Material");
qputenv("QT_STYLE_OVERRIDE", "Material");
// FIX: Force Qt to look in the system plugin directory for drivers (Arch Linux specific)
// This fixes the "Driver not loaded" error when running from Qt Creator
qputenv("QT_PLUGIN_PATH", "/usr/lib/qt6/plugins");
QGuiApplication app(argc, argv);
QQuickStyle::setStyle("Material");
// Initialize Database
DatabaseManager dbManager;
if (!dbManager.connectToDatabase()) {
qWarning() << "Failed to connect to database. Check credentials in DatabaseManager.cpp";
}
QQmlApplicationEngine engine;
// Register LibraryModel - Main book list model
LibraryModel libraryModel;
engine.rootContext()->setContextProperty("libraryModel", &libraryModel);
// Register SearchModel - Search and filter model
SearchModel searchModel;
engine.rootContext()->setContextProperty("searchModel", &searchModel);
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("Mwanatech", "Main");
return app.exec();
}