Re: Unset Data by role
When you call setData(), you are changing the model, so the only way to "unset" the model is to call setData() again with the default color. The model doesn't have any memory of its state before you made the change so it can't undo a change on its own.
Now I'm trying to 'unset' just the color I set to the model.
If you don't know the default color, simply call data() with Qt:: BackgroundRole -before- you make any changes to the model. Save this color somewhere so you can use it to restore the original color. An easy way might be to call setData() with Qt:: UserRole and save it there if your model allows that.
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.