PDA

View Full Version : Coloring a QTableview column



Potch
4th April 2009, 22:58
Hello,

So far I use the following way to color the colum of a tableview :


// Color the colum
for (int i = FirstLine; i < Max_Number_of_Lines; i++)
InputDataModel->setData(InputDataModel->index(i, SelectedColumn), SelectedVariableColor, Qt::BackgroundRole);


It works but it is very slow when Max_Number_of_Lines is greater than 2000. Then I have to wait 2 or 3s before it's colored.

Would you know if there is a faster (and more clever) way to proceed ?

Thanks in advance

talk2amulya
4th April 2009, 23:11
create your own item delegete
derive it from QStyledItemDelegate
override the paint function
use the option variable to get the rect and fill it with ur color(read about it from Qt Assistant first)
set this delegate on ur choice of column using setItemDelegateForColumn

Potch
4th April 2009, 23:18
Ok thanks.
I will follow your advises.