[Interest] Problems when updating view/delegate
norulez at me.com
norulez at me.com
Fri Feb 3 23:28:34 CET 2012
Hi,
I tried to overload the setData() function as followed, but the behavior is the same which means that the view/delegate doesn't get updated:
bool ret = QStandardItemModel::setData(index, value, role);
emit dataChanged(this->index(0, 0), this->index(rowCount(), columnCount()));
return ret;
I also tried:
.) to update only the changed row => same effect:
emit dataChanged(this->index(index.row(), 0), this->index(index.row(), columnCount()));
.) calling a QTimer::singleShot(500) in the setData() => same effect
.) deactivate the QSortFilterProxyModel and use only the QStandardItemModel => same effect
.) various combinations from those points => same effect
Do I need to do something special for the delegate and/or for the view?
Best Regards
Am 03.02.2012 um 21:01 schrieb Bo Thorsen <bo at fioniasoftware.dk>:
> The way I would do this is to make a custom role for the background and
> use that to paint the background in the delegate.
>
> You have to emit dataChanged() for the cells where the background should
> be updated as well as the column2 cells for the delegates to be notified
> about the change.
>
> Bo.
>
> Den 03-02-2012 11:47, norulez at me.com skrev:
>> Hello @all,
>>
>> lets say I have a model with 5 columns and 3 rows.
>>
>> The delegate should set the background color for the individual rows depending on which value is in column 2.
>>
>> Now my main problem is that when I change the value of column 2, then only the background of column 2 is changed.
>>
>> How can I update the view so that all columns are updated?
>>
>> mytableview->repaint is too expensive.
>>
>> Thanks in advance
>>
>> Best Regards
>> NoRulez
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
>
> Bo Thorsen,
> Fionia Software.
>
> --
>
> Expert Qt and C++ developer for hire
> Contact me if you need expert Qt help
> http://www.fioniasoftware.dk
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list