[PyQt] Incorrect base for wrapped class
Phil Thompson
phil at riverbankcomputing.co.uk
Wed Jul 4 15:00:10 BST 2007
On Wednesday 04 July 2007 2:31 pm, Kelly Burkhart wrote:
> On 7/3/07, Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> > On Tuesday 03 July 2007 6:28 pm, Kelly Burkhart wrote:
>
> <snip>
>
> > > Built my class and see the same results.
> >
> > And it's Python bindings I assume. Are you sure you don't have another
> > copy of the PyQt .sip files somewhere which are being picked up instead
> > of the ones you've just installed.
>
> I did a find in /usr and /opt for *.sip. Aside from the correct sip
> files which are in /usr/share/sip/PyQt4, the only other sip files I
> see on my machine are in /opt/kde3/share/sip.
>
> If I strace my sip command and grep for the opens, I see that sip is
> opening the sip files in /usr/share/sip/PyQt4 (which all have a
> timestamp of yesterday when I reinstalled).
>
> > > If I change the base class of my c++ class, I get seemingly random
> > > different bases when imported in python:
> > >
> > > QObject --> PyQt4.QtCore.QAbstractFileEngineHandler
> > > QIODevice --> PyQt4.QtCore.QMimeData
> > > QFile --> PyQt4.QtCore.QFileSystemWatcher
> > >
> > > Any other ideas?
> >
> > I'd then start to distrust your own Python bindings, but I would say that
> > wouldn't I.
> >
> > A lot of the internals of a SIP generated module are table driven. The
> > order in which things appear in tables is dependent on the .sip files. If
> > the .sip files don't match then one module might be using the wrong table
> > index.
>
> I can't see anything wrong in my installation. I've created a trivial
> test extension and can run that on my home machine with different
> linux version, different Qt version, different PyQt version and get
> the same results. If I'm installing something wrong, I'm at least
> consistently installing wrong, and the only symptom is that I cannot
> build a sip extension.
>
> Would you mind downloading this? <http://www.kkcsm.net/pqtext.tar.gz>
>
> You should be able to modify the first few lines of the makefile
> appropriately and do this:
>
> $ export LD_LIBRARY_PATH=`pwd`
> $ make
> $ ./tst.py
>
> When I run this I see my classes base to be <class
> 'PyQt4.QtCore.QFileSystemWatcher'> when I believe it should be QFile.
> I'm hoping you'll be able to reproduce my failure, or show that
> everything works well when properly installed. (at which point I'll
> be doomed).
You need to pass the same -t flags to your invocation of sip as were used when
you built PyQt. The following bit of Python tells you what they were...
from PyQt4 import pyqtconfig
print pyqtconfig.Configuration().pyqt_sip_flags
Without it, when building your module, SIP thinks PyQt is built for an older
version of Qt with some classes missing. You then get the mismatch in those
tables I was talking about.
Phil
More information about the PyQt
mailing list