Skip to content

Commit c9a2929

Browse files
committed
added getNativeVariable
1 parent 9ace39e commit c9a2929

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/PythonQt.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO
575575
// if the object is a derived object, we want to switch the class info to the one of the derived class:
576576
if (name!=(qptr->metaObject()->className())) {
577577
info = _knownClassInfos.value(qptr->metaObject()->className());
578-
if (!info) {
578+
if (!info || (info->pythonQtClassWrapper() == NULL)) {
579579
registerClass(qptr->metaObject());
580580
info = _knownClassInfos.value(qptr->metaObject()->className());
581581
}
@@ -1021,6 +1021,16 @@ QVariant PythonQt::getVariable(PyObject* object, const QString& objectname)
10211021
return result;
10221022
}
10231023

1024+
QVariant PythonQt::getNativeVariable(PyObject* object, const QString& objectname)
1025+
{
1026+
QVariant result;
1027+
PythonQtObjectPtr obj = lookupObject(object, objectname);
1028+
if (obj) {
1029+
result = QVariant::fromValue(obj);
1030+
}
1031+
return result;
1032+
}
1033+
10241034
QStringList PythonQt::introspection(PyObject* module, const QString& objectname, PythonQt::ObjectType type)
10251035
{
10261036
QStringList results;

src/PythonQt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ class PYTHONQT_EXPORT PythonQt : public QObject {
400400
//! get the variable with the \c name of the \c object, returns an invalid QVariant on error
401401
QVariant getVariable(PyObject* object, const QString& name);
402402

403+
//! get the variable with the \c name of the \c object as QVariant of type PythonQtObjectPtr, returns an invalid QVariant on error
404+
QVariant getNativeVariable(PyObject* object, const QString& name);
405+
403406
//! read vars etc. in scope of an \c object, optional looking inside of an object \c objectname
404407
QStringList introspection(PyObject* object, const QString& objectname, ObjectType type);
405408
//! read vars etc. in scope of the given \c object

0 commit comments

Comments
 (0)