[PyKDE] Are QLayout's iterators broken?
Baz Walter
bazwal at ftml.net
Sat Jul 2 17:29:24 BST 2005
Hello List
I've been trying to adjust the layout of a QFileDialog after customising it
using addWidgets(). I've tried to access the block of widgets at the bottom
of the dialog using layout iterators, but something seems to be broken. The
QLayoutItems produced by the iterators are all 'sterile'. That is, their own
iterators don't produce anything and their layout(), widget(), and
spacerItem() methods all return None. It's possible to 'cheat' a bit by using
QObject methods to access child layouts - but this still ends up with the
useless 'sterile' QLayoutItems at some point.
Here's some sample output to show what I mean:
>>> from qt import *
>>> a = QApplication([])
>>> d = QFileDialog()
>>> d.layout().activate()
>>> ## this is cheating...
... p = d.layout().children()[1]
>>> (isinstance(p,QLayoutItem),isinstance(p,QObject))
(True, True)
>>> print (p.layout(),p.widget(),p.spacerItem())
(<qt.QVBoxLayout object at 0xb7d467ac>, None, None)
>>> ## not cheating...
... c = p.iterator().current()
>>> (isinstance(c,QLayoutItem),isinstance(c,QObject))
(True, False)
>>> print (c.layout(),c.widget(),c.spacerItem())
(None, None, None)
>>> print (c.isEmpty(), c.iterator().current())
(False, None)
>>> ## cheating again...
... c = p.children()[0]
>>> (isinstance(c,QLayoutItem),isinstance(c,QObject))
(True, True)
>>> print (c.layout(),c.widget(),c.spacerItem())
(<qt.QHBoxLayout object at 0xb7d467dc>, None, None)
>>> print (c.isEmpty(), c.iterator().current())
(False, <qt.QLayoutItem object at 0xb7d4674c>)
>>> ## not cheating...
... i = c.iterator().current()
>>> type(i).mro()
[<class 'qt.QLayoutItem'>, <type 'sip.wrapper'>, <type 'object'>]
>>> print (i.layout(),i.widget(),i.spacerItem())
(None, None, None)
>>> print i.geometry().rect()
(11, 14, 47, 16)
That last QLayoutItem corresponds with the 'Look in' label at the top of the
dialog. Shouldn't it be a QWidgetItem? It would have to be for i.widget() to
return a QLabel - wouldn't it?
BTW, I am using python 2.4.1 pyqt 3.14.1 and sip 4.2.1
Thanks for any thoughts you might have on this.
--
Baz Walter
More information about the PyQt
mailing list