Here the dual value editor that is instantiated in delegate.createEditor method with

Qt Code:
  1. QWidget * QStyledItemDelegate::createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index )
  2. {
  3. return new EvaDualValEditor(new QDateTimeEdit(parent), new QDateTimeEdit(parent), parent);
  4. }
To copy to clipboard, switch view to plain text mode 

... and it looks like in table edit mode. After tabbing (cursor on blue marked) the editor is closed and the next cell is selected.
dualValEditor.jpg


Qt Code:
  1. // header
  2. class EvaDualValEditor : public QWidget
  3. {
  4. Q_OBJECT
  5.  
  6. public:
  7. explicit EvaDualValEditor(QWidget* editor1, QWidget* editor2, QWidget *parent = 0);
  8. ~EvaDualValEditor();
  9.  
  10. void setValues( QVariant& param1, QVariant& param2 );
  11.  
  12. protected:
  13.  
  14. private:
  15. QHBoxLayout *horizontalLayout_2;
  16. QLabel *label;
  17. QWidget *wgt1;
  18. QLabel *label_2;
  19. QWidget *wgt2;
  20.  
  21. void init();
  22. };
  23.  
  24. // implementation
  25.  
  26. EvaDualValEditor::EvaDualValEditor(QWidget* editor1, QWidget* editor2, QWidget* parent /*= 0*/)
  27. : QWidget(parent)
  28. , wgt1(editor1)
  29. , wgt2(editor2)
  30. {
  31. init();
  32. }
  33.  
  34. EvaDualValEditor::~EvaDualValEditor()
  35. {
  36. }
  37.  
  38. void EvaDualValEditor::init()
  39. {
  40.  
  41. setFocusPolicy (Qt::StrongFocus);
  42. setFocusProxy(wgt1);
  43. setTabOrder(wgt1, wgt2);setObjectName(QString::fromUtf8("EvaDualValEditor"));
  44.  
  45. horizontalLayout_2 = new QHBoxLayout(this);
  46. horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
  47. horizontalLayout_2->setSpacing(1);
  48. horizontalLayout_2->setContentsMargins(1, 1, 1, 1);
  49.  
  50. label = new QLabel(this);
  51. label->setObjectName(QString::fromUtf8("label"));
  52.  
  53. horizontalLayout_2->addWidget(label);
  54.  
  55. wgt1->setObjectName(QString::fromUtf8("widget"));
  56.  
  57. horizontalLayout_2->addWidget(wgt1);
  58.  
  59. label_2 = new QLabel(this);
  60. label_2->setObjectName(QString::fromUtf8("label_2"));
  61.  
  62. horizontalLayout_2->addWidget(label_2);
  63.  
  64. wgt2->setObjectName(QString::fromUtf8("widget_2"));
  65.  
  66. horizontalLayout_2->addWidget(wgt2);
  67.  
  68. }
  69.  
  70. void EvaDualValEditor::setValues( QVariant& param1, QVariant& param2 )
  71. {
  72. if (wgt1 && !param1.isNull())
  73. {
  74. qobject_cast<QDateTimeEdit*>(wgt1)->setDateTime(param1.toDateTime());
  75. }
  76. if (wgt2 && !param2.isNull())
  77. {
  78. qobject_cast<QDateTimeEdit*>(wgt2)->setDateTime(param2.toDateTime());
  79. }
  80. }
To copy to clipboard, switch view to plain text mode