Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
Description
Implement a way so that the user can emit Qt Signals from the Python data model. The handling of the signals will be done in QML. If the signals are not handled in QML, a warning will be produced that the signal is not handled in QML.
Current idea is to expose a function to Python code
def emit(signal_name: str, *args) -> None:
Example:
// Python code
class FileDownloaderModel: def __init__(self): super().__init__() def download_file(self, url: str) -> None: print(f"Downloading {url}") # this call onDownloadCompleted in QML emit_signal("downloadCompleted", url) #infer type from Url or use QVariant downlaoder = FileDownloaderModel() AutoQmlBridge(downloader, data_type="List")
// QML Code
import QtQuick 2.15 import QtQuick.Controls 2.15 import backend 1.0 ApplicationWindow { ... Connections { target: FileDownloaderModel onDownloadCompleted: { console.log("Download completed for: " + url) } } }
Attachments
Issue Links
- is required for
-
QTBUG-134668 As a dev, I need a simple way to add a Qt Quick UI to my Python code
-
- In Progress
-