I have a tableView which uses a DoubleSpinBoxDelegate as an editor. That itself works fine.

But If I repaint the whole model after one entry has changed (because all the other entries depend on that value), the editor does not close and all other editors do not work anymore.

The delegates are set up using
Qt Code:
  1. // delay
  2. delegateSpinBox = new DoubleSpinBoxDelegate(this) ;
  3. delegateSpinBox->setEditor(new QDoubleSpinBox(this));
  4. delegateSpinBox->setLocalLanguage(QLocale::German);
  5. delegateSpinBox->Editor()->setRange(10,20e7);
  6. delegateSpinBox->Editor()->setDecimals(3);
  7. delegateSpinBox->Editor()->setSingleStep(1);
  8. tableViewVariation->setItemDelegateForColumn(4,delegateSpinBox);
To copy to clipboard, switch view to plain text mode 

The model entries have to change in case the delay changes:

Qt Code:
  1. void widgetCouplerVariationList::OnTableDataChanged(const QModelIndex & index)
  2. {
  3. int col = index.column();
  4. int row = index.row();
  5.  
  6. switch(col)
  7. {
  8. case 4: // delay
  9. {
  10. double delay = index.data().toDouble();
  11. (*VariationList)[row].delay = delay;
  12. updateModelList();
  13. break;
  14. }
  15. } // end switch
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void widgetCouplerVariationList::updateModelList()
  2. {
  3. size_t size = VariationList->size();
  4. if (size > 0)
  5. {
  6. double length = 0;
  7.  
  8. modelVariationList->blockSignals(true);
  9. // modelVariationList->clear();
  10. modelVariationList->setRowCount(size);
  11. modelVariationList->setColumnCount(5);
  12.  
  13. int column = 0;
  14.  
  15. item = new QStandardItem(QString("lines")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
  16. item = new QStandardItem(QString("period")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
  17. item = new QStandardItem(QString("graylevel")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
  18. item = new QStandardItem(QString("chirp")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
  19. item = new QStandardItem(QString("delay")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
  20. item = new QStandardItem(QString("length")); modelVariationList->setHorizontalHeaderItem(column, item); column++;
  21.  
  22. tableViewVariation->verticalHeader()->setDefaultSectionSize(tableViewVariation->verticalHeader()->minimumSectionSize()+2);
  23.  
  24. for (int i = 0; i < (int)size ; i++)
  25. {
  26.  
  27. double velocity = CouplerSettings.Velocity;
  28. double chirp = (*VariationList)[i].chirp * 1e3;
  29. double delay = (*VariationList)[i].delay;
  30. double phase = (*VariationList)[i].phase;
  31. length = length + velocity*delay*1e-3;
  32. int column = 0;
  33.  
  34. QStandardItem *newItem;
  35. newItem = new QStandardItem(QString("%L1").arg((*VariationList)[i].powerIndex + 1));
  36. modelVariationList->setItem(i, column, newItem); column++;
  37.  
  38. newItem = new QStandardItem(QString("%L1").arg((*VariationList)[i].period,0,'f',3));
  39. modelVariationList->setItem(i, column, newItem); column++;
  40.  
  41. newItem = new QStandardItem(QString("%L1").arg(int(phase)));
  42. //newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
  43. modelVariationList->setItem(i, column, newItem); column++;
  44.  
  45. newItem = new QStandardItem(QString("%L1").arg(chirp,0,'f',4));
  46. modelVariationList->setItem(i, column, newItem); column++;
  47.  
  48. newItem = new QStandardItem(QString("%L1").arg(delay,0,'f',3));
  49. modelVariationList->setItem(i, column, newItem); column++;
  50.  
  51. newItem = new QStandardItem(QString("%L1").arg(length,0,'f',3));
  52. modelVariationList->setItem(i, column, newItem); column++;
  53.  
  54. }
  55. tableViewVariation->setModel(modelVariationList);
  56. modelVariationList->blockSignals(false);
  57. }
  58. }
To copy to clipboard, switch view to plain text mode 


Now if 'updateModelList()' gets called from within 'OnTableDataChanged(const QModelIndex & index)' the editors of delegates do not work anymore and the current one does no vanish.