前言
上位机通过 Python 丰富的软件包,调用系统的硬件资源,在 QML 中进行交互,比如通过上位机点击按键打开 Python 串口功能,并上报 Python 串口数据到 QML 界面。
- QML 中调用 Python 方法
- Python 数据上报到 QML:信号方式
实现
- 自定义类
PythonLogic.py
from PySide6.QCore import QObject, Slot, Signal
class PythonLogic(QObject):
sig = Signal(list)
@Slot()
def say_hello(self):
print("Hello from Python!")
self