[PyKDE] Problem with layout iterators

Baz Walter bazwal at ftml.net
Sat Jul 9 14:53:00 BST 2005

Hello again

My earlier post on this got no response, so I suppose my description of the 
problem was no good :-(

So - I hope this is a bit clearer:

QLayoutIterator should produce objects which *inherit* QLayoutItem (such as a 
QLayout, QWidgetItem or QSpacerItem). However, it currently produces only 
"bare" QLayoutItems:

>>> # using python 2.4.1 pyqt 3.14.1 and sip 4.2.1
>>> from qt import *
>>> a = QApplication([])
>>> d = QFileDialog()
>>> c = d.layout().iterator().current()
>>> type(c).mro()
[<class 'qt.QLayoutItem'>, <type 'sip.wrapper'>, <type 'object'>]

This is wrong, because QLayoutItem is an abstract class only intended for 
sub-classing. It matters, because a "bare" QLayoutItem can only produce empty 
iterators and has no access to the object it is laying out:

>>> if not c.isEmpty(): repr(c.iterator().current())
>>> repr(c.layout()) # sub-class would return a QHBoxLayout, here

Can this be fixed, so that only the correct sub-classes are produced by the 
layout iterators, please?

Baz Walter

More information about the PyQt mailing list