
Originally Posted by
wysota
Thanks for your help.
That's what I was thinking, too. I just didn't know how to check for an opened editor.
This is what you have to do:
Connect the dataChanged signal to a custom slot updateEditor.
In your custom model, you need a pointer to the view, called tview here.
Then, in customEditor, you can call indexWidget on the view which returns the editor widget. Here a sample code:
void MyDelegate::updateEditor(const QModelIndex& start, const QModelIndex& end)
{
QWidget* widget
= tview
->indexWidget
(start
);
if (widget)
{
switch(start.column())
{
// edit only these columns, leave out others
case col1:
case col2:
case col4:
{
setEditorData(widget, start);
break;
}
default:
break;
}
}
}
void MyDelegate::updateEditor(const QModelIndex& start, const QModelIndex& end)
{
QWidget* widget = tview->indexWidget(start);
if (widget)
{
switch(start.column())
{
// edit only these columns, leave out others
case col1:
case col2:
case col4:
{
setEditorData(widget, start);
break;
}
default:
break;
}
}
}
To copy to clipboard, switch view to plain text mode
Of course, you have to do some more necessary checks.
If there is an easier way, please let me know.
Regards,
Rainer
Bookmarks