python - Nested Layouts ... Drawn stacked not layered -


ok ... missing it. trying have dialog created has gridlayout number of checkbox's , below accept, close pushbutton in hboxlayout. following code see gridlayout on top of hboxlayout. why? how can dimension dialog width of gridlayout?

class checkerdialog(qtgui.qdialog) :      def __init__(self, parent, headers) :         super(checkerdialog, self).__init__(parent)          checkslayout = qtgui.qgridlayout()         self.cblist = []          = 0         y in range(13):             x in range (9):                 if == len(headers) : break                 cb = qtgui.qcheckbox(headers[i], self)                 cb.move(offset_x + spacer_x*x, offset_y + spacer_y*y)                 self.cblist.append(cb)                 += 1          buttonlayout = qtgui.qhboxlayout()         applybutton = qtgui.qpushbutton("apply")         closebutton = qtgui.qpushbutton("close")         buttonlayout.addwidget(applybutton)                 buttonlayout.addwidget(closebutton)         self.connect(applybutton, qtcore.signal('clicked()'), self._apply)         self.connect(closebutton, qtcore.signal('clicked()'), self.close)          checkerlayout = qtgui.qvboxlayout()         checkerlayout.addlayout(buttonlayout)         checkerlayout.addlayout(checkslayout) 

  1. the hboxlayout on top of gridlayout - not beneath it.

yes, should in code. sequence has effect in code.

    checkerlayout.addlayout(buttonlayout) # <- top     checkerlayout.addlayout(checkslayout) # <- bottom 

if want set widget specifies index, can use qboxlayout.insertlayout (self, int index, qlayout layout, int stretch = 0);

    checkerlayout.insertlayout(1, buttonlayout) # <- bottom     checkerlayout.insertlayout(0, checkslayout) # <- top 

  1. and size of gridlayout not control size of overall layout,

yes, should in code (again). because not put check box in qgridlayout. set geometry on root layout not qgridlayout. pleas use qgridlayout.addwidget (self, qwidget, int row, int column, qt.alignment alignment = 0) add widget specifies index (x, y);

little example:

import sys pyqt4 import qtgui  class qcheckerdialog (qtgui.qdialog):     def __init__ (self, parent = none) :         super(qcheckerdialog, self).__init__(parent)          checkboxqgridlayout = qtgui.qgridlayout()         y in range(13):             x in range(9):                 currentqcheckbox = qtgui.qcheckbox('%d, %d' % (x, y))                 currentqcheckbox.setsizepolicy(qtgui.qsizepolicy(qtgui.qsizepolicy.minimum, qtgui.qsizepolicy.minimum))                 checkboxqgridlayout.addwidget(currentqcheckbox, x, y)          buttonqhboxlayout  = qtgui.qhboxlayout()         applyqpushbutton = qtgui.qpushbutton('apply')         closeqpushbutton = qtgui.qpushbutton('close')         buttonqhboxlayout.addwidget(applyqpushbutton)                 buttonqhboxlayout.addwidget(closeqpushbutton)          allqvboxlayout = qtgui.qvboxlayout()         allqvboxlayout.insertlayout(1, buttonqhboxlayout)         allqvboxlayout.insertlayout(0, checkboxqgridlayout)         self.setlayout(allqvboxlayout)  myqapplication = qtgui.qapplication(sys.argv) myqqcheckerdialog = qcheckerdialog() myqqcheckerdialog.show() sys.exit(myqapplication.exec_()) 

see also:

qboxlayout.insertlayout (self, int index, qlayout layout, int stretch = 0) reference

qgridlayout.addwidget (self, qwidget, int row, int column, qt.alignment alignment = 0) reference


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -