May 2019
Intermediate to advanced
542 pages
13h 37m
English
The reviews table contains a column with a date; while we can certainly edit dates using a regular QLineEdit, it would be nicer if we could use the more appropriate QDateEdit widget. Unlike the situation with our coffee list view, Qt doesn't have a ready-made delegate that will do this for us. Fortunately, we can easily create our own delegate:
class DateDelegate(qtw.QStyledItemDelegate): def createEditor(self, parent, option, proxyModelIndex): date_inp = qtw.QDateEdit(parent, calendarPopup=True) return date_inp
The delegate class inherits QStyledItemDelegate, and its createEditor() method is responsible for returning the widget that will be used for ...
Read now
Unlock full access