[PyQt] Incorrect base for wrapped class
phil at riverbankcomputing.co.uk
Tue Jul 3 22:12:22 BST 2007
On Tuesday 03 July 2007 6:28 pm, Kelly Burkhart wrote:
> On 7/3/07, Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> > On Tuesday 03 July 2007 4:05 pm, Kelly Burkhart wrote:
> > > Greetings,
> > >
> > > I am trying to wrap QAbstractTableModel. When I instantiate my code,
> > >
> > > it shows an incorrect base class:
> > > >>> from PyQt4 import QtGui, QtCore
> > > >>> from ecn.gui.log_view_model_base import LogViewModelBase
> > > >>> print LogViewModelBase.__base__
> > >
> > > <class 'PyQt4.QtCore.QProcess'>
> > >
> > >
> > > LogViewModelBase is a sip wrapper of a trivial class derived from
> > > QAbstractTableModel. I have no idea how QProcess gets chosen as a
> > > base (incidentally, if I derive from QAbstractItemMode, QIODevice is
> > > chosen as base).
> > >
> > > Can anyone provide a hint as to what I am doing wrong or failing to
> > > specify? Thanks!
> > This typically happens when a different version of SIP has been used to
> > build the different modules, or a different set of PyQt .sip files were
> > used.
> > Try rebuilding all the SIP generated modules.
> Thanks for the reply Phil, however that doesn't appear to fix things.
> Here's what I've done since last night:
> Built qt with following config: ./configure -prefix /opt/qt -qt-gif
> Note, the only Qt executables in the path are the ones in /opt/qt/bin.
> Built sip 4.6:
> ...> tar xzf sip-4.6.tar.gz
> ...> cd sip-4.6
> ...> python configure.py -p linux-g++-64
> ...> make
> ...> sudo make install
> Built QScintilla:
> ...> tar xzf QScintilla-1.73-commercial-2.1.tar.gz
> ...> cd QScintilla-1.73-commercial-2.1
> .../QScintilla-1.73-commercial-2.1> cd Qt4/
> .../QScintilla-1.73-commercial-2.1/Qt4> qmake qscintilla.pro
> .../QScintilla-1.73-commercial-2.1/Qt4> make
> .../QScintilla-1.73-commercial-2.1/Qt4> sudo make install
> Built PyQt:
> ...> tar xzf PyQt-x11-commercial-4.2.tar.gz
> ...> cd PyQt-x11-commercial-4.2
> .../PyQt-x11-commercial-4.2> cp ../pyqt-commercial.sip sip/
> .../PyQt-x11-commercial-4.2> python ./configure.py
> .../PyQt-x11-commercial-4.2> make
> .../PyQt-x11-commercial-4.2> sudo make install
> 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.
> 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
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.
More information about the PyQt