PDA

View Full Version : QAbstractTableModel , custom data



akon
17th April 2009, 16:03
i am trying to color a particular column in AbstractTableModel. But I wonder why its not working.........Here is the code snipp....
thanks.


function ColorModel(parent)
{
QAbstractTableModel.call(this, parent);
}
ColorModel.prototype= new QAbstractTableModel();

ColorModel.prototype.rowCount= function (QModelIndex)
{
return 2;
}

ColorModel.prototype.columnCount= function (QModelIndex)
{
return 5;
}
ColorModel.prototype.color=function(){
return new QColor(127, 200 , 24);
}
ColorModel.prototype.data = function(index, role)
{
var dataR;
if (role == Qt.DisplayRole) {
return 5;
}
if (role == Qt.BackgroundRole) {
if (index.column() == 1)
//return new QColor(127, 200 , 24);
return this.color;
//var color = new RGBColor('darkblue');
}

return dataR;
}