From e9fdfd40aa9a7032c75382dbcd0fa688762d3085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Mon, 11 May 2020 23:02:08 +0200 Subject: [PATCH] Add comment for Q_DELEGATE. --- src/runner/pythonrunner.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index c9bc844..7d4aa6b 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -41,6 +41,14 @@ using namespace MOBase; namespace bpy = boost::python; namespace mp11 = boost::mp11; +/** + * This macro should be used within a bpy::class_ declaration and will define two + * methods: __getattr__ and Name, where Name will simply return the object as a QClass* + * object, while __getattr__ will delegate to the underlying QClass object when required. + * + * This allow access to Qt interface for object exposed using boost::python (e.g., signals, + * methods from QObject or QWidget, etc.). + */ #define Q_DELEGATE(Class, QClass, Name) \ .def(Name, +[](Class* w) -> QClass* { return w; }, bpy::return_value_policy()) \ .def("__getattr__", +[](Class* w, bpy::str str) -> bpy::object { \