def createEditor(self, parent, option, index): """ Crée le widget utilisé pour éditer la valeur d'une cellule Retourne un widget "vierge", i.e. ce n'est pas ici qu'on initialise la valeur du widget. En revanche, c'est ici qu'on peut définir les valeurs min/max acceptées, etc. https://doc.qt.io/qt-5/model-view-programming.html#providing-an-editor """ editor = QDateTimeEdit(parent=parent) editor.setMinimumDate( datetime.datetime(year=2017, month=9, day=1, hour=8, minute=30)) editor.setMaximumDate( datetime.datetime(year=2030, month=9, day=1, hour=18, minute=30)) editor.setDisplayFormat("yyyy-MM-dd HH:mm") #editor.setCalendarPopup(True) # setFrame(): tell whether the line edit draws itself with a frame. # If enabled (the default) the line edit draws itself inside a frame, otherwise the line edit draws itself without any frame. editor.setFrame(False) action = QAction(editor) # <- action.setShortcut(Qt.CTRL | Qt.Key_Delete) # <- #action.setShortcut(Qt.Key_Delete) # the keyevent for the suppr key is already catched by the editor thus it doesn't work... action.triggered.connect( lambda: self.deleteActionCallback(editor, index)) # <- editor.addAction(action) # <- return editor
def createEditor(self, parent, option, index): editor = QDateTimeEdit(parent=parent) editor.setMinimumDate(datetime.datetime(year=2017, month=9, day=1, hour=8, minute=30)) editor.setMaximumDate(datetime.datetime(year=2020, month=9, day=1, hour=18, minute=30)) editor.setDisplayFormat("yyyy-MM-dd HH:mm:ss") #editor.setCalendarPopup(True) # setFrame(): tell whether the line edit draws itself with a frame. # If enabled (the default) the line edit draws itself inside a frame, otherwise the line edit draws itself without any frame. editor.setFrame(False) return editor
def createEditor(self, parent, option, index): editor = QDateTimeEdit(parent=parent) editor.setMinimumDate( datetime.datetime(year=2017, month=9, day=1, hour=8, minute=30)) editor.setMaximumDate( datetime.datetime(year=2020, month=9, day=1, hour=18, minute=30)) editor.setDisplayFormat("yyyy-MM-dd HH:mm:ss") #editor.setCalendarPopup(True) # setFrame(): tell whether the line edit draws itself with a frame. # If enabled (the default) the line edit draws itself inside a frame, otherwise the line edit draws itself without any frame. editor.setFrame(False) return editor
def createEditor(self, parent, option, index): if index.column() in DATE_TIME_COLUMN_LIST: editor = QDateTimeEdit(parent=parent) #editor.setMinimumDate(datetime.datetime(year=2018, month=1, day=1, hour=0, minute=0)) #editor.setMaximumDate(datetime.datetime(year=2020, month=9, day=1, hour=18, minute=30)) editor.setDisplayFormat(QT_DATE_TIME_FORMAT) #editor.setCalendarPopup(True) # setFrame(): tell whether the line edit draws itself with a frame. # If enabled (the default) the line edit draws itself inside a frame, otherwise the line edit draws itself without any frame. editor.setFrame(False) return editor else: return QStyledItemDelegate.createEditor(self, parent, option, index)
def createEditor(self, parent, option, index): """ Crée le widget utilisé pour éditer la valeur d'une cellule Retourne un widget "vierge", i.e. ce n'est pas ici qu'on initialise la valeur du widget. En revanche, c'est ici qu'on peut définir les valeurs min/max acceptées, etc. https://doc.qt.io/qt-5/model-view-programming.html#providing-an-editor """ editor = QDateTimeEdit(parent=parent) editor.setMinimumDate( datetime.datetime(year=2017, month=9, day=1, hour=8, minute=30)) editor.setMaximumDate( datetime.datetime(year=2030, month=9, day=1, hour=18, minute=30)) editor.setDisplayFormat("yyyy-MM-dd HH:mm") #editor.setCalendarPopup(True) # setFrame(): tell whether the line edit draws itself with a frame. # If enabled (the default) the line edit draws itself inside a frame, otherwise the line edit draws itself without any frame. editor.setFrame(False) return editor