[PyQt] noob woes (but still making progress)

David Boddie david at boddie.org.uk
Wed May 16 00:30:48 BST 2007


On Tue May 15 22:37:09 BST 2007, Jason Hihn wrote:

> Well my question is because %TypeHeaderCode is only usable in a class
> definition. So, I can't do a global %TypeHeaderCode, and have it apply to
> all classes in the file. So I do not know that using the same
> %TypeHeaderCode multiple times for the same .h file is legal.

It is legal. It is done, for example, in PyQt4's sip/QtDesigner/extension.sip
file for the QAbstractExtensionFactory and QAbstractExtensionManager classes.

> Also, I am not clear on %Import vs %Include. What is the difference between
> %importing a sip and %Including it?

Unless I'm mistaken, importing a .sip file tells SIP where to look for more
information about classes you've referenced but not defined, whereas
including a .sip file copies in the file's contents.

For example, in PyQt4's QtGuimod.sip, there's

%Import QtCore/QtCoremod.sip

which tells SIP that the classes in QtGuimod.sip use information from
QtCoremod.sip, then there's

%Include qabstractbutton.sip
%Include qabstractitemdelegate.sip
%Include qabstractitemview.sip

and so on, which bring in the contents of those files for processing as
part of the QtGui module.

If you're relying on an external module that's already wrapped and built,
you probably want to use %Import. If you're collecting .sip files together
to create your own module, you probably want to use %Include. Unless I'm
mistaken, of course - there are others here who do this more often than
I do.

David


More information about the PyQt mailing list