QItemDelegate *delegate = new QItemDelegate; QItemEditorFactory *editorFactory = new QItemEditorFactory; QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<WidgetClassName>(); editorFactory->registerEditor(QVariant::UserType, creator); delegate->setItemEditorFactory(editorFactory);
QItemEditorFactory *editorFactory = new QItemEditorFactory; QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<MyFancyDateTimeEdit>(); editorFactory->registerEditor(QVariant::DateType, creator);
QStandardItemModel* model = new QStandardItemModel(1,5);MyWidget *widget = new MyWidget;QItemDelegate *itemDelegate = new QItemDelegate;QItemEditorFactory *editorFactory = new QItemEditorFactory;QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<MyWidget>();editorFactory->registerEditor(QVariant::UserType, creator);itemDelegate->setItemEditorFactory(editorFactory);QModelIndex index = model->index(0, 0, QModelIndex());itemDelegate->setEditorData(widget, model, index );QTableView *table = new QTableView;table->setModel(model);