[PyKDE] Re: Disappearing Layout Widget

Chad Brantly cbrantly at darwin.sfbr.org
Tue Aug 16 22:02:06 BST 2005


James Emerton wrote:
> It should be possible to navigate the various layout's children to get
> at the correct instance.    

This method did work.  I was able to walk get the children of the layout and
add my ListView to the child (QGridLayout).  In my case, the QGridLayout is
the only child, so I just chose layout().childrent()[0], but I suppose that
you could check the type of each child if there were multiple children.  

> May I suggest that it might me simpler to use a placeholder.  Use
> designer to place a QFrame where you'd like to add your control
> programmatically.

Come on...where is your sense of adventure?  That would be way to easy!

Here is a simplified version of my code in case someone else runs into the
same problem:

>From ui.py:
=================
class Form1(QMainWindow):
  def __init__(self,parent=None,name=None,fl=0):
    QMainWindow.__init__(self,parent,name,fl)
    *snip*
    self.GroupBox=QGroupBox(self.SearchTab,"GroupBox")
    GroupBoxLayout=QGridLayout(self.GroupBox.layout())

>From main.py:
=================
class Form2(ui.Form1, QMainWindow):
  def __init__(self, parent=None, name=None, fl=0):
    ui.Form1.__init__(self, parent, name, fl)
    self.GroupBoxLayout=self.GroupBox.layout().children()[0]
    self.GroupBoxLayout.addMultiCellWidget(self.myListView,0,0,0,4)




More information about the PyQt mailing list