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.
--
Giovanni Bajo

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to