[PyKDE] Re: Bug with QScrollView viewport binding

Phil Thompson phil at riverbankcomputing.co.uk
Wed Jun 29 15:36:37 BST 2005


On Wednesday 29 June 2005 3:21 pm, Giovanni Bajo wrote:
> Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> > Yes - but they aren't in existence at the same time.
> > [...]
> > Using a temporary name to keep a reference to sv.viewport() solves the
> > problem.
>
> Then you have the inverse problem:
>
> ----------------------------------------------
> from qt import *
>
> app = QApplication([])
> sv = QScrollView(None)
> w = QWidget(sv.viewport())
>
> p = w.parent()
> print sv.viewport().width()
> ----------------------------------------------
> Traceback (most recent call last):
>   File "D:\Work\caligola3d\src\pyqtbug3.py", line 9, in ?
>     print sv.viewport().width()
> AttributeError: width
>
> which is wrong because viewport() is supposed to return a QWidget pointer.

It sees that it has already been wrapped (as a QObject) and just returns an 
extra reference. It doesn't try to retype the existing wrapper, or create a 
new wrapper to the same C++ instance with the more specific type.

Phil




More information about the PyQt mailing list