PDA

View Full Version : QTable Widget



kavinsiva
22nd October 2009, 14:24
Hi,


How to set the TableWidgetItem As readonly ?

Bye

jano_alex_es
22nd October 2009, 14:33
When I had to do a non editable QTableWidget I used QTableView instead.

But maybe you can do it just setting the flag Qt::ItemIsSelectable for each QTableWidgetItem.

kapoorsudhish
22nd October 2009, 16:50
Or this code might help

QTableWidgetItem *newItem = new QTableWidgetItem(tr(""));
newItem->setFlags( Qt::ItemIsEnabled );
This flag setting will make the Table Widget item Non Editable, and the widget will be enabled.

ChrisW67
23rd October 2009, 01:46
You probably want to remove the Qt::ItemIsEditable and Qt::ItemIsUserCheckable flags from the item potentially preserving the others (e.g if the item is a tristate check box or draggable).

jano_alex_es
23rd October 2009, 09:15
But if you remove the flags Qt::ItemIsEditable and Qt::ItemIsUserCheckable the table changes it visibility... the text of each cell appears like "disabled" (gray) and it's not intuitive.

That's why I had to use QTableView instead.

kavinsiva
23rd October 2009, 13:50
But if you remove the flags Qt::ItemIsEditable and Qt::ItemIsUserCheckable the table changes it visibility... the text of each cell appears like "disabled" (gray) and it's not intuitive.

That's why I had to use QTableView instead.

Hi Thankyou to Your reply,

I found some way to set as readonly


QTableWidgetItem *newItem2 = new QTableWidgetItem;
newItem2->setFlags(newItem2->flags() & (~Qt::ItemIsEditable));


it set particular cell as Read only