View Full Version : QTableView enable
Daxos
29th June 2010, 15:50
Hi,
I have a Qtableview in my project and i want that the first column is editable but not the second column.
How i can setEnebled(false) only for the second column?
Thanks, Bye
xray2000
30th June 2010, 07:47
Hi, i think you can solve this problem in two ways:
1. if you use own model class you can reipliment flags method like this:
Qt::ItemFlags Model::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
if (index.column() == 1)
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
2. Or just use delegation mechanism - subclass QStyledItemDelegate, reimplement necessary methods in particular method createEditor (should return 0 for second column index). Set up delegation class to you QTableView class using setItemDelegateForColumn method
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.