[PyQt] Designer plugins with non-default QString/etc. SIP API versions

Phil Thompson phil at riverbankcomputing.com
Wed Jan 4 14:14:37 GMT 2012


On Wed, 4 Jan 2012 01:52:08 +0100, Fabian Knittel
<fabian.knittel at lettink.de> wrote:
> Hi,
> 
> we're currently migrating our Python 2.x PyQt4 code from
> QString/QVariant/... SIP API version 1 to version 2 in preparation for
> Python 3. The app works fine and we're quite happy with API version 2.
> 
> Unfortunately, our app specific Qt Designer plugins have stopped
> working. The plugins use code from the app and therefore now depend on
> API version 2, but the PyQt designer plugin loader loads
> PyQt4.QtDesigner.QPyDesignerCustomWidgetPlugin before loading any of
> our plugins and therefore the API version gets set to the default
> (version 1).
> 
> The attached patch lazy loads
> PyQt4.QtDesigner.QPyDesignerCustomWidgetPlugin after the first
> successful plugin module import. Assuming full control over all
> plugins and further assuming that all plugins use the same API
> versions, this allows the plugins to call sip.setapi before any
> default APIs are set.
> 
> Would something like this be acceptable upstream?
> 
> Cheers
> Fabian
> 
> PS: The patch is against 4.7.3, but (as far as I can tell) 4.9 doesn't
> appear to have changed much in designer/pluginloader.cpp

Applied - thanks.

I've also changed it so that plugins are loaded in alphabetical order so
that you can control which is the first plugin and have a dummy plugin that
just sets the API versions.

Phil


More information about the PyQt mailing list