Prevent text to be drawn over the clear edit icon

This commit is contained in:
Laurent Monin
2014-07-15 17:55:09 +02:00
parent d7622c2ffc
commit 994da0b1ac

View File

@@ -87,6 +87,9 @@ class ButtonLineEdit(QtGui.QLineEdit):
self.clear_button.setToolTip(_("Clear entry"))
self.clear_button.clicked.connect(self.clear)
self.textChanged.connect(self._update_clear_button)
self._margins = self.getTextMargins()
def _update_clear_button(self, text):
self.clear_button.setVisible(text != "")
left, top, right, bottom = self._margins
self.setTextMargins(left, top, right + self.clear_button.width(), bottom)