Clearing QDateEdit and QLabel
-
wrote on 25 Oct 2021, 14:37 last edited by
Is there a way to set QDateEdit and QLabel containing an image to empty string like the example below? I have tried this method and it is not working for me. Please any assistance. Thank you.
QdateEdit method 1: dob = self.ui.dateEdit.clear() QdateEdit method 2: dob = self.ui.dateEdit.setText("") QLabel method 1: self.ui.Display_label.setPixmap(QPixmap(pixmap)).clear()
-
Hi
QDateEdit cannot be empty. ( it resets to 01-01-2000)Regarding the QLabel. This can contain emoty text but what you mean with the
image/icon ?Like an icon with nothing drawn ?
-
Is there a way to set QDateEdit and QLabel containing an image to empty string like the example below? I have tried this method and it is not working for me. Please any assistance. Thank you.
QdateEdit method 1: dob = self.ui.dateEdit.clear() QdateEdit method 2: dob = self.ui.dateEdit.setText("") QLabel method 1: self.ui.Display_label.setPixmap(QPixmap(pixmap)).clear()
-
Is there a way to set QDateEdit and QLabel containing an image to empty string like the example below? I have tried this method and it is not working for me. Please any assistance. Thank you.
QdateEdit method 1: dob = self.ui.dateEdit.clear() QdateEdit method 2: dob = self.ui.dateEdit.setText("") QLabel method 1: self.ui.Display_label.setPixmap(QPixmap(pixmap)).clear()
wrote on 25 Oct 2021, 14:43 last edited by Pl45m4dateedit.clear()
should work
The second method wont work, sinceQDateEdit
has no functionsetText
.For your
QLabel
try:
self.ui.Display_label.clear()
Edit:
@eyllanesc was faster :) -
Hi
QDateEdit cannot be empty. ( it resets to 01-01-2000)Regarding the QLabel. This can contain emoty text but what you mean with the
image/icon ?Like an icon with nothing drawn ?
-
@mrjj thanks for your response. The Qlabel uses the QFileDialog.getOpenFilename() method to load an image into the QLabel with a help of a QPushButton.
So you want to "CLEAR" the icon also ?
Update. Clear() also removes the icon :) -
wrote on 26 Oct 2021, 08:51 last edited by
@eyllanesc Thanks for your response. The .clear() worked.
3/9