Qt Designer custom widgets (was Re: [PyKDE] Relaise of PyQt4?)

David Boddie david at boddie.org.uk
Wed Mar 8 18:12:31 GMT 2006

On Mon, 6 Mar 2006 14:07:44, Phil Thompson wrote:

> The first (and only planned) beta will be out this month. Current snapshots
> should be perfectly usable - but that's for others to say.
> All the structural changes are now in place, it's now only a question of
> going through the (very short) list of outstanding issues.

As you know, I was working on making changes to the way PyQt handles
meta-objects to enable things like properties and inheritance to be shown
correctly for Python widgets in Qt Designer. This required some changes
to the qobject.sip and qobjectdefs.sip files, as well as some nasty
patching tricks after SIP had generated the source code.

My plan was to work on this a bit more, but I ran into problems with
Python's garbage collector and didn't feel confident enough to tackle them.

Another approach I've since considered is to just implement a C++ plugin
to manage Python custom widgets. This "easy option" might be preferable
but depends on what people want or expect from Python widgets:

 1. Is it useful to allow Python subclasses of QObject to define their
    own Qt compatible properties? C++ subclasses declare properties with
    Q_PROPERTY. Python objects could just use descriptors and have them
    recognized when registered with the meta-object system.

 2. Is it useful to obtain information about the base classes of an
    object via Qt's meta-object system when Python's object system
    can provide that information in a more "Pythonic" way?

 3. Is it easier for tools like pyuic4 to initialize custom widget
    properties using Python's own property system or with Qt's property
    system? Would these tools be harder to write if you couldn't use
    just one scheme to access object properties regardless of the
    implementation language?

It turns out that getting Python custom widgets loaded in Qt Designer is
easy. The hard part is making them behave like good citizens there, so that
you can actually do useful things with them.


More information about the PyQt mailing list