[PyQt] PyqtProperty types

Kyle Altendorf sda at fstab.net
Tue Aug 30 00:30:16 BST 2016


On 2016-08-29 15:31, David Morris wrote:
> On Mon, Aug 29, 2016 at 8:27 PM, Lais P. Carmo <lais.carmo at lnls.br> 
> wrote:
> 
>> 2) How can I create a property which is composed by others? An example 
>> of this kind is the property geometry of QWidget class: it is composed 
>> by X, Y, Width and Height properties.
> 
> Don't over think this, it is not complicated.  You have functions used 
> to get and set each property value ... anything can be done inside a 
> function.  _Anything._  Just recombine data in a different format.   A 
> property doesn't even have to be connected to a real variable if you 
> have a way of generating the data.

I know we can return anything but in either form of a pyqtProperty 
definition you are supposed to specify the type of the property in 
addition to returning something of that type.  I would think that while 
the Python side of things might be ok with that, I would not expect the 
C++/Qt side to fare so well.  Also, how would Qt Designer know how to 
handle the type.  Even if we take the simple approach of a compound 
property containing other properties, in what structure?  A regular 
class inheriting from QObject?  A dict?  An ordered dict?  I tried a few 
but they didn't work with various errors.

Does anyone have examples of compound typed pyqtProperty's?  If it's 
possible I would love to learn how.

Cheers,
-kyle


More information about the PyQt mailing list