[PyQt] Multiple inheritance with item views

Jugdish jugdizh at gmail.com
Mon Feb 22 21:09:28 GMT 2010

The reason I have BaseView inheriting from QAbstractItemView is because
inside it I make calls like:


and so on. These are all things that are common to both
MyTreeView/MyTableView, and obviously wouldn't work if BaseView had no base

Any ideas of a better way to achieve this without duplicating code between
the 2 views?


On Mon, Feb 22, 2010 at 8:45 PM, Andreas Pakulat <apaku at gmx.de> wrote:

> On 22.02.10 19:45:31, Jugdish wrote:
> > I have my own subclasses of QTreeView and QTableView, called MyTableView
> and
> > MyTreeView. There is a lot of code that is common between my 2 classes,
> so
> > to avoid having tons of duplicate code, I was thinking of having a base
> > class derived from QAbstractItemView that they both derive from.
> This is not possible. All three Qt classes are subclasses of QObject
> which doesn't support inheriting from it multiply (directly or
> indirectly). You may get undefined behaviour wrt. Qt signal/slots and
> who knows what else. However, nothing stops you from not having a base
> class for your BaseView at all.
> Andreas
> --
> A long-forgotten loved one will appear soon.
> Buy the negatives at any price.
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100222/712ddf7c/attachment-0001.html>

More information about the PyQt mailing list