Allow only scriptable methods and properties #74
-
What is the recommended way, to allow only scriptable methods (annotated with Should I filter the data when doing introspection ( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ok, I have found the solution. The relevant file is QStringList PythonQtClassInfo::propertyList()
{
QStringList l;
if (_isQObject && _meta) {
int i;
int numProperties = _meta->propertyCount();
for (i = 0; i < numProperties; i++) {
QMetaProperty p = _meta->property(i);
if (!p.isScriptable()) {
l << QString(p.name());
}
}
}
QStringList members = memberList();
foreach(QString member, members) {
if (member.startsWith("py_get_")) {
l << member.mid(7);
}
}
return l;
}
QStringList PythonQtClassInfo::memberList()
{
decorator();
QStringList l;
QString h;
// normal slots of QObject (or wrapper QObject)
if (_meta) {
int numMethods = _meta->methodCount();
bool skipQObj = !_isQObject;
for (int i = skipQObj?QObject::staticMetaObject.methodCount():0; i < numMethods; i++) {
QMetaMethod m = _meta->method(i);
if ((m.attributes() & QMetaMethod::Scriptable) &&
(((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public)
|| m.methodType()==QMetaMethod::Signal))
{
l << PythonQtUtils::methodName(m);
}
}
} |
Beta Was this translation helpful? Give feedback.
Ok, I have found the solution. The relevant file is
PythonQtClassInfo
and the relevant methods arpropertyList
andmemberList
. I added tests for scriptable attributes and this worked: