How to simply delete row in QFormLayout programatically
layout, pyqt, qt
Solution
You can just schedule the widget and its label (if it has one) for deletion, and let the form adjust itself accordingly. The label for the widget can be retrieved using labelForField.
Python Qt code:
label = myQformLayout.labelForField(myEdit)
if label is not None:
label.deleteLater()
myEdit.deleteLater()
Problem
I have this code: ``` myEdit = QLineEdit() myQFormLayout.addRow("myLabelText", myEdit) ``` Now I have to remove the row by reference to `myEdit` only: ``` myQformLayout.removeRow(myEdit) ``` But there is no API for that. I can use `.takeAt()`, but how can I get the argument? How do I find the label index, or the index of `myEdit`?