[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Re: Bug ovverriding sizeHint
From: Phil Thompson <phil () riverbankcomputing ! co ! uk>
Date: 2008-02-25 9:29:27
Message-ID: 200802250929.27901.phil () riverbankcomputing ! co ! uk
[Download RAW message or body]
On Friday 22 February 2008, Giovanni Bajo wrote:
> Hi,
>
> consider this snippet:
>
> =======================================================
> from PyQt4.Qt import *
> app = QApplication([])
> w = QWidget()
> L = QVBoxLayout(w)
> L.addWidget(QLabel("ciao", w))
>
> called_class = []
> class MyScrollArea(QScrollArea):
> def sizeHint(self):
> called_class.append(1)
> return QSize(100,100)
>
> called_func = []
> def mySizeHint(*args):
> called_func.append(1)
> return QSize(100,100)
>
> sv = MyScrollArea(w)
> sv.sizeHint = mySizeHint # the trick!
>
> L.addWidget(sv)
> L.activate()
> assert not called_class
> assert called_func
> =======================================================
> Traceback (most recent call last):
> File "sizehint.py", line 24, in ?
> assert called_func
> AssertionError
>
> My understanding is that the function "mySizeHint()" should be called
> while calculating the size, as it was overridden. What happens is that,
> misteriously, *neither* sizeHint() function is called.
>
> Of course, if you comment the marked line, the overridden method is
> called, as expected.
SIP is looking for a method to invoke - not just a callable. See the
implementation of sip_api_is_py_method() in siplib.c.
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic