PDA

View Full Version : script tableview problems..



akon
6th April 2009, 15:06
hi,
how can I set the following properties using script... atleast I didnt find any prototype or properties to set this. And I wonder paint and resize event is not also available......any idea is appreciating

setAutoScroll(false);
setSelectionMode(QAbstractItemView.SingleSelection );
setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff );
setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff);

thanks

akon
7th April 2009, 08:57
function XPainter (parent){
QAbstractItemDelegate.call(this, parent);
}

XPainter.prototype= new QAbstractItemDelegate();

XPainter.prototype.sizeHint = function (option, index){
return new QSize(45,45);
}

XPainter.prototype.paint= function(painter,option,index){
if (option.state & QStyle.State_Selected)
{
painter.fillRect(option.rect, QColor(0,60,38));
}
// painter.setPen(QColor(254,251,236));
// var rect= option.rect;
// painter.drawText(rect.x, rect.y, rect.width, rect.height, Qt.AlignCenter, "tech", //undefined);
delete painter;
}

function mViewModel(parent,cdate)
{
QTableView.call(this, parent);
var xModel = new XMODEL(parent,fstDate);
initView = new QTableView(parent);

initView.setModel(xModel);
var selectionModel = new QItemSelectionModel(xModel);
initView.setSelectionModel(selectionModel);
initView.cornerButtonEnabled=false;
var xPainter = new XPainter(this);
initView.setItemDelegate(xPainter);
}

if I setItemDelegate, I cant see any data in tableview. model and data set is fine, i just started scripting...so plz any kind of sugges.. will be helpful