Issue
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
?
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()
Answered By - ekhumoro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.