From 226a49a523ca02822d7219c3a1f64e085460147cc4ded37e8a074b4c9ca48220 Mon Sep 17 00:00:00 2001 From: linuxero Date: Wed, 13 Nov 2024 23:34:51 +0100 Subject: [PATCH] QRC for QML resources --- gui/qmldir | 2 ++ main.py | 6 ++++++ pyqcrm.pyproject | 5 +++-- qml.qrc | 2 ++ rc_qml.py | 13 ++++++++++++- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 gui/qmldir diff --git a/gui/qmldir b/gui/qmldir new file mode 100644 index 0000000..3822178 --- /dev/null +++ b/gui/qmldir @@ -0,0 +1,2 @@ +module TopBar +TopBar 1.0 TopBar.qml diff --git a/main.py b/main.py index 920b0a4..ac63f9d 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import sys from pathlib import Path from PySide6.QtGui import QGuiApplication from PySide6.QtQml import QQmlApplicationEngine +from PySide6.QtCore import QResource from lib.ConfigLoader import ConfigLoader from lib.DataBase import DataBase import rc_pyqcrm @@ -36,14 +37,19 @@ def testConnection(): if __name__ == "__main__": + # QResource.registerResource("qml.qrc") app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() + engine.addImportPath("qrc:/gui"); + bad_config = False qml_file = Path(__file__).resolve().parent / "gui/main.qml" + # qml_file = ":/gui/TopBar.qml" + config = ConfigLoader() con = testConnection() diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index 6335840..8974769 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -8,7 +8,6 @@ "gui/Dashboard.qml", "js/qmldict.js", "lib/Vermasseln.py", - "gui/TopBar.qml", "gui/CustomerTables.qml", "gui/SearchBar.qml", "gui/test.qml", @@ -16,6 +15,8 @@ "gui/EmployeTables.qml", "gui/AddCustomer.qml", "pyqcrm.qrc", - "qml.qrc" + "qml.qrc", + "gui/qmldir", + "gui/TopBar.qml" ] } diff --git a/qml.qrc b/qml.qrc index 8282fd4..db0fb5a 100644 --- a/qml.qrc +++ b/qml.qrc @@ -1,5 +1,7 @@ + gui/qmldir gui/TopBar.qml + diff --git a/rc_qml.py b/rc_qml.py index cf2d32d..47adc72 100644 --- a/rc_qml.py +++ b/rc_qml.py @@ -36,6 +36,11 @@ R\xc2\x99\x15\xe6\xba7\xf5\xb1\x85]\xd9d4\xe6\x0c\ 6\x9e\x93%!~\x0d`\x01_\xdb(\x5c\xa0\xa7\x82\ \x03\xf0\xd6\xb8\x0d\x97\xd8n\x056\x87\xb4\xaf%\xb4\x0d\ \x83\xfb\x1b\xe6\x8aD\x22w*\ +\x00\x00\x00$\ +m\ +odule TopBar\x0aTop\ +Bar 1.0 TopBar.q\ +ml\x0a\ " qt_resource_name = b"\ @@ -47,13 +52,19 @@ qt_resource_name = b"\ \x08\x8e<\xbc\ \x00T\ \x00o\x00p\x00B\x00a\x00r\x00.\x00q\x00m\x00l\ +\x00\x06\ +\x07\x84+\x02\ +\x00q\ +\x00m\x00l\x00d\x00i\x00r\ " qt_resource_struct = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\ \x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00&\x00\x00\x00\x00\x00\x01\x00\x00\x01\xbe\ +\x00\x00\x01\x93'\x9ft\xf1\ \x00\x00\x00\x0c\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00\ \x00\x00\x01\x93'4I\xe1\ "