jmalicke
18th October 2014, 18:50
I have a custom delegate that renders a QComboBox in a table cell.
In my custom table model I have an implementation of setData:
bool ParametersMapTableModel::setData(const QModelIndex & index, const QVariant & value, int32_t role)
{
...
if (index.column() == COL_COMBO_BOX)
{
theDataSource.theSelectedString = value.toString();
}
The problem is that value.toString() returns the value of the selected index, not the string value in the QComboBox.
What is the best way to get the string of the selected index from within setData()?
Of course I can maintain my own QStringList of indexes to strings. I am not sure how to maintain my own list without tightly coupling the model to the view.
In my custom table model I have an implementation of setData:
bool ParametersMapTableModel::setData(const QModelIndex & index, const QVariant & value, int32_t role)
{
...
if (index.column() == COL_COMBO_BOX)
{
theDataSource.theSelectedString = value.toString();
}
The problem is that value.toString() returns the value of the selected index, not the string value in the QComboBox.
What is the best way to get the string of the selected index from within setData()?
Of course I can maintain my own QStringList of indexes to strings. I am not sure how to maintain my own list without tightly coupling the model to the view.