First of all, as mentioned in the docs, Qt::TextColorRole is obsolete and you should not use it. Use Qt::ForegroundRole instead.
Second, as mentioned by @alex_malyu, it depends on the model whether or not it implements that. QStandardItemModel for example will, but your custom model might not.
So the question is what is your model class.