My first post so apologies if I have fractured any rules!!
I have created a custom delegate from QItemDelegate, i have reimplemented the virtual functions to createEditor() to create the widget, setEditorData() and set the setModalData().
It all works well for cell 0,0 but when trying to edit other cells, 0,1 for example, the editing widget is painted into cell 0,0 Once the edit (completed in cell 0,0) is complete the correct value is entered into cell 0,1.
If someone can explain why the widget is always painted to cell 0,0 or provide a link to something that explains my problem I would be very grateful.
QWidget *tDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const
{
QComboBox *editor = new QComboBox(parent);
QStringList tempUnits;
tempUnits << "Celcius" << "Fahrenhiet" << "Rankin" << "Delisle" << "Newton" << "Reaumur" << "Romer" << "Kelvin";
for (int i=0; i<tempUnits.size();i++)
{
editor->addItem(tempUnits.at(i));
}
editor->setCurrentIndex(0);
return editor;
}
Qt Code:
{ Q_ASSERT(combo); combo->setCurrentIndex(combo->findText(value)); }To copy to clipboard, switch view to plain text mode
Bookmarks