|
DAWorkbench 0.0.1
DAWorkbench API
|
Python线程到Qt主线程的通信处理器 更多...
#include <DAPythonSignalHandler.h>
类 | |
| class | FunctionWrapper |
Public 类型 | |
| using | FunctionWrapperPtr = std::shared_ptr< FunctionWrapper > |
信号 | |
| void | executeRequested (int funcWrapperId) |
| 内部信号,用于触发主线程执行 | |
Public 成员函数 | |
| DAPythonSignalHandler (QObject *parent=nullptr) | |
| DAPythonSignalHandler (const DAPythonSignalHandler &)=delete | |
| DAPythonSignalHandler & | operator= (const DAPythonSignalHandler &)=delete |
| void | callInMainThread (std::function< void() > func) |
| 从Python线程调用,请求在主线程执行函数 | |
| void | clearPendingFunctions () |
| 清理所有待执行的函数 | |
Python线程到Qt主线程的通信处理器
这个类允许Python线程通过信号槽机制安全地调用Qt主线程中的函数 非单例模式,由主窗口或其他容器管理生命周期
| void DA::DAPythonSignalHandler::callInMainThread | ( | std::function< void() > | func | ) |
从Python线程调用,请求在主线程执行函数
| func | 要在主线程执行的函数 |
这个函数是线程安全的,可以从任何线程调用
| void DA::DAPythonSignalHandler::clearPendingFunctions | ( | ) |
清理所有待执行的函数
在主窗口销毁前调用,确保所有函数都被清理
|
signal |
内部信号,用于触发主线程执行
| funcWrapperId | 函数包装器的唯一ID |