[PyKDE] [cappy2112@gmail.com: re:Multiple layouts on same Window]

Andreas Pakulat apaku at gmx.de
Fri Jan 26 22:15:42 GMT 2007


Please stay on the list.

What I see there: The QWidget doesn't have a
parent, which means it is not a child of your dialog. Also it's show()
method is never called, so it doesn't display.
And last but not least: You don't need the QWidget, just set the layout
on the dialog.

----- Forwarded message from Tony Cappellini <cappy2112 at gmail.com> -----

*Hello Andreas,

Thanks for the reply.

I've added 2 QVBoxLayouts as children of the QHBoxLayout.
A tiny window appears without any widgets.
What have I not done correctly?

class Dialog(QtGui.QDialog):

   def __init__(self,parent=None):
       QtGui.QDialog.__init__(self, parent)

       self.window = QtGui.QWidget()

       self.button1 = QtGui.QPushButton("One")
       self.button2 = QtGui.QPushButton("Two")
       self.button3 = QtGui.QPushButton("Three")
       self.button4 = QtGui.QPushButton("Four")

       self.h_layout = QtGui.QHBoxLayout()
       self.v1_layout = QtGui.QVBoxLayout()
       self.v2_layout = QtGui.QVBoxLayout()

       self.v1_layout.addWidget(self.button1)
       self.v1_layout.addWidget(self.button2)
       self.v2_layout.addWidget(self.button3)
       self.v2_layout.addWidget(self.button4)

       self.h_layout.addChildLayout(self.v1_layout )
       self.h_layout.addChildLayout(self.v2_layout)

       self.window.setLayout(self.h_layout)


def main(args):


   try:
       app = QtGui.QApplication(args)
       dialog = Dialog()
       dialog.window.show()
       sys.exit(app.exec_())
   except ImportError:
       print"\n%s.py could not be found" % 'nm2g2'






Andreas Pakulat* apaku at gmx.de
<pykde%40mats.imk.fraunhofer.de?Subject=%5BPyKDE%5D%20Multiple%20layouts%20on%20same%20Window&In-Reply-To=8249c4ac0701251507m158fce4ch571775677bdfa53b%40mail.gmail.com>
*Fri Jan 26 00:33:13 MET 2007*

  - Previous message: [PyKDE] Multiple layouts on same Window
  <http://mats.imk.fraunhofer.de/pipermail/pykde/2007-January/015293.html>
  - Next message: [PyKDE] Re: embedding python widgets in C++ app
  <http://mats.imk.fraunhofer.de/pipermail/pykde/2007-January/015295.html>
  - *Messages sorted by:* [ date
]<http://mats.imk.fraunhofer.de/pipermail/pykde/2007-January/date.html#15294>
[
  thread 
]<http://mats.imk.fraunhofer.de/pipermail/pykde/2007-January/thread.html#15294>
[
  subject 
]<http://mats.imk.fraunhofer.de/pipermail/pykde/2007-January/subject.html#15294>
[
  author 
]<http://mats.imk.fraunhofer.de/pipermail/pykde/2007-January/author.html#15294>

------------------------------

On 25.01.07 15:07:46, Tony Cappellini wrote:
>* Using this as a reference
*>* http://doc.trolltech.com/4.1/qvboxlayout.html#details
*>*
*>* I want to have two QVboxLayouts side by side, with buttons 6-10 in another
*>* QVBoxLayout on the same window.
*>* Ideally, there would be one vertical stack of widgets on the left, and
*>* another stack of vertical widgets on the right.
*>*
*>* Do I need to add another layout or container to the window first, in order
*>* to add 2 QVboxlayouts, side by side?
*
Yes, possibly a QHBoxLayout and then add the 2 vboxes as childlayouts of
that layout.

Andreas

----- End forwarded message -----

-- 
Celebrate Hannibal Day this year.  Take an elephant to lunch.




More information about the PyQt mailing list