PDA

View Full Version : Item edit in QTableWidget



manmohan
27th April 2011, 19:51
Hi,
I have created a small program, I have observed several thing in QTableWidget, even though we disable the TabKey Navigation, it still works. How to disable the Tabkey Navigation in QtableWidget? if I click on the 1st column of any row it allows me to edit where as it should. I have attached the code in zip file please help me out with this.


6305
Thanks
manmohan.

john_god
28th April 2011, 01:46
I have removed your connection in the constructor and added the following:


for(int r=0;r<ui->tableWidget->rowCount();r++)
for(int c=0;c<ui->tableWidget->columnCount();c++)
{
ui->tableWidget->item(r,c)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
}

It works now.

manmohan
29th April 2011, 03:32
Thanks John,
The tab key navigation is disabled. In the table I want to disable editing of the 1st column, and the rest of the 2 columns should be editable by mouse clicks only (not by tab key navigation).


for(int r=0;r<ui->tableWidget->rowCount();r++)
for(int c=0;c<ui->tableWidget->columnCount();c++)
{
if(c == 0)
ui->tableWidget->item(r,c)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
}


Thanks and regards.
Manmohan

john_god
29th April 2011, 16:56
Then, optimize it


for(int r=0;r<ui->tableWidget->rowCount();r++)
{
ui->tableWidget->item(r,0)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
}