3

I am trying to use simple example code I've found in Google.
Everything works except as soon as I set the delegate for the column, it's displaying gets buggy.
Here are the line where I set the "Bank" string as a value for both rows and comboboxdelegate.cpp
Here's a screenshot of MainWindow
screenshot
The question is, if the data is stored in model, why is it not displayed properly? Because if I change the value using combobox, what is displayed in cell still stays as shown in screenshot. However pressing button shows that data in model has been changed

P.S. I am not concerned about editor not being persistently visible, I'm concerned about displayed cell value being something else.

mekkanizer
  • 722
  • 2
  • 9
  • 28

1 Answers1

1

I had to change the line QString text = items[index.row()].c_str() to index.data(Qt::DisplayRole).toString().
So while painting the delegate Qt will access data stored in model, not in delegate's option vector
I also had to change model->setData(index, _editor->currentIndex()); to model->setData(index, _editor->currentText());

mekkanizer
  • 722
  • 2
  • 9
  • 28