C++ (Qt)QWidget *DateTimeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex&) const{ QDateTimeEdit *editor = new QDateTimeEdit(parent); connect(editor, &QDateTimeEdit::editingFinished, this, &DateTimeDelegate::_commitAndCloseEditor); editor->setDisplayFormat("dd.MM.yyyy hh:mm:ss"); return editor;}
C++ (Qt)void DateTimeDelegate::_commitAndCloseEditor(){ QDateTimeEdit *editor = qobject_cast<QDateTimeEdit*>(sender()); if(this->_value == editor->text()) return; emit commitData(editor); emit editingFinished(editor->property("row").toInt(), editor->dateTime().toString(Qt::ISODate)); emit closeEditor(editor);}
if (index.column() == 2 && role == Qt::EditRole && rowTable.value("date_record").toDate() != value.toDate())