QVariant convert to QBrush
I am working with a QTreeview.
index_data = treeview.model.data(index, QT::ForegroundRole)
> 66 -> QBrush
So all indications are that the QVariant was converted to QBrush,
however I am unable to call any QBrush functions on idex_data.
I am doing all of this in Squish
I am ultimately looking for the color of text in the index.
Hi and welcome to devnet,
you should rather use
QBrush brush = index_data.value<QBrush>(); //modify brush treeview->model()->setData(index, brush, Qt::ForegroundRole);
Hope it helps
The color of the text is already set. I am testing that the color is correct.
When I convert the QVariant to a QBrush I expect that I can call color()
and verify that it was set properly. However when I convert the Qvariant to QBrush the functions available to me are those of the QVariant not QBrush. Is there a better way to get text color from an QModelIndex?
QBrush brush = index_data.value<QBrush>();
There you have your QBrush object you want to test
Unfortunately Squish does not allow me to use the same syntax that you are using.
I tried multiple variations of your code all give me <type 'exceptions.AttributeError'>.
I am contacting them. Thanks for the help.