[PyKDE] Problem with layout iterators

Phil Thompson phil at riverbankcomputing.co.uk
Sat Jul 9 16:05:22 BST 2005


On Saturday 09 July 2005 2:53 pm, Baz Walter wrote:
> 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())
>
> 'None'
>
> >>> repr(c.layout()) # sub-class would return a QHBoxLayout, here
>
> 'None'
>
> Can this be fixed, so that only the correct sub-classes are produced by the
> layout iterators, please?

How? Qt doesn't provide the type information that would be needed to do this.

Phil




More information about the PyQt mailing list