[PyKDE] pyqt and new-style classes

Ulrich Berning ulrich.berning at desys.de
Fri Feb 20 11:01:01 GMT 2004


Roland Schulz schrieb:

>On Do, 2004-02-19 at 11:55, Ulrich Berning wrote:
>  
>
>>Phil Thompson schrieb:
>>    
>>
>>>On Wednesday 18 February 2004 19:04, Eron Lloyd wrote:
>>>      
>>>
>
>  
>
>>Nevertheless it makes sense to implement QMetaObject and
>>QMetaProperty, just in case someone plans to build a kind of dialog
>>editor with PyQt (in the future, we want to give our customers the
>>facility to create or modify dialogs or dialog components inside the
>>application).
>>    
>>
>
>I have done a lib to insert PyQt Widget as Plugin in QtDesinger with
>editable properties (if you interested in this search for qtdesinger or
>qwidgetplugin in the mail archive or just ask me). Jim, David and Phil
>helped me to see that there is no point in implementing QMetaObject in
>PyQt but do a Proxy in C++. The main reason were:
>There is little use for those MetaObjects functions from Python space.
>Even if you write a dialog editor in PyQt you would use the Qt functions
>and they would query the MetaObjects. So even in this case those queries
>would come from C++ space.
>>From C++ space it looks like every class is a object of one of the
>wrapper class even if it only indirectly subclass of a wrapper class. So
>from C++ space it seams that e.g. a python object of a QWidget class has
>the same class as a object of a python class derived from QWidget. Since
>most of the MetaObject stuff is done with statics this would complicate
>it further.
>Like I said, just ask or look at the archives for more information.
>
>regards
>Roland
>
>
>  
>
I'm not talking about Designer plugins or about creating new widget 
classes with PyQt, that can be used in a dialog editor. I'm talking 
about querying the properties of the existing Qt widget classes.

If I would build a dialog editor, creating widgets would be done in the 
following way:
1.) The user selects a Qt widget class from a toolbox.
2.) The dialog editior creates an instance of that widget class and 
places it into the dialog window.
3.) The dialog editor sets up a property editor to modify the properties 
of that widget instance.

In C++, I can use QObject::metaObject() to get the QMetaObject of the 
widget.
Then I can do QMetaObject::numProperties() to get the number of 
properties and in a loop QMetaObject::property() to get all 
QMetaProperty instances.
The QMetaProperty instances have all the necessary informations, needed 
to set up a property editor.
This will work for most of the Qt widget classes, only a few widget 
classes may need special handling.
In PyQt, I can't do this, because the above classes and methods are not 
implemented. The only way to manage this in PyQt, is to write a huge 
amount of code for every widget class, to set up a property editor for 
that widget class. Another disadvantage of doing it this way is that 
with every new Qt release, the property definitions of a widget class 
may have changed, so the code does not work any longer.


Ulli





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20040220/f07c9928/attachment.html


More information about the PyQt mailing list