[Qt-interest] updating model data simultaneousy from a view and code

Kishore kitts.mailinglists at gmail.com
Thu Feb 26 11:41:36 CET 2009


I am experiencing an issue with modifying my model data from a view. It 
generally works but i have one issue.

I am in the situation where the model is continuously update in code. The 
update happens several times in a second. Now what i need is that when the 
user double clicks to update the value manually, the value to default to is 
the value that was set at that moment and then the user edits it (the model is 
still updated in the background) and hits 'enter'.

What happens now is that the user is unable to edit values as the value is 
continuously reset to the value as updated in the background.

Currently, my code looks something like this:
QVariant PropertyModel::data(const QModelIndex& index, int role) const
{
        if(role == Qt::DisplayRole)
            return m_values[index.row()];
         else if(role == Qt::EditRole)
            return m_values[index.row()];

    return QVariant();
}

Commenting the lines:
         else if(role == Qt::EditRole)
            return m_values[index.row()];
does not seem to help either. The only difference it makes is that the edit now 
does not know the datatype and defaults to QString but still clears out user 
input while being typed.

How may i work this out?
-- 
Cheers!
Kishore



More information about the Qt-interest-old mailing list