Hallo,

inserting widgets with a negative index does not work as expected. I was expecting -1 to add a widget to the end and -2 to insert it right before the last widget in the layout. Is my assumption wrong?

Demo code:

from PyQt4.QtGui import QLineEdit, QCheckBox, QPushButton, QDialog, QFormLayout, \
    QVBoxLayout, QApplication

class Gui(QDialog):
    def __init__(self):
        QDialog.__init__(self)

        editLayout = QFormLayout()
        editLayout.addRow("enter something:", QLineEdit())

        editLayout.addRow("enter another something:", QLineEdit())

        button = QPushButton("press me")

        layout = QVBoxLayout()
        layout.addLayout(editLayout)
        layout.addWidget(button)

        self.setLayout(layout)

        self.layout().insertWidget(-2, QCheckBox("check me!"))

app = QApplication([])
g = Gui()
g.show()
app.exec_()

cheers

Sebastian

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to