[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] objectName properties set in QML not accessible in python
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2017-11-10 13:32:44
Message-ID: BF9421A0-55AB-48AB-8ADC-84D548B3E7FB () riverbankcomputing ! com
[Download RAW message or body]

On 9 Nov 2017, at 3:31 pm, Russell Warren <russ@perspexis.com> wrote:
> 
> When you set the `objectName` property of a QObject that has been registered for \
> QML use with `qmlRegisterType`, the resulting `objectName` is not accessible in \
> python. 
> See this small self-contained example of the issue:
> 
> https://gist.github.com/rwarren/995e7ddc373f7119c51737fcd4aba0cc
> 
> Although this can be worked around by defining a replacement `objectName` property \
> in python (see below), it seems like this should not be required. Equivalent C++ \
> code, for example, has no issue accessing the objectName that was set in QML. 
> The workaround is to use alternative/back-door means to set/get the \
> `QObject.objectName` property with something like this replacement property \
> definition in the registered class: 
> @pyqtProperty(str)
> def objectName(self):
> return QtCore.QObject.objectName(self)
> 
> @objectName.setter
> def objectName(self, objectName):
> QtCore.QObject.setObjectName(self, objectName)
> 
> Is there a fundamental reason that objectName can't be accessed in PyQt? It would \
> be nice to not have to use that workaround.

Under the covers there is some proxying going on. Qt does not provide any means to \
intercept or detect the necessary calls.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic