PDA

View Full Version : set column as not editable in Qtablewidget



Vidhya
31st July 2012, 11:03
connect(ui->widget,SIGNAL(cellDoubleClicked(int,int)),this,SLO T(column_check(int,int)));


void Saleorder::column_check(int row,int column)
{
QTableWidgetItem* itemtot=ui->widget->item(row, 9);

if( column == 9 )
{
if (itemtot && !itemtot->text().isEmpty())
{
itemtot->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
}

}
}
i tried this but the program is crashed.

Any one help me solve the problem.

Is there is any other way to achieve to make the entire column as not editable

Thanks in advance

sonulohani
31st July 2012, 11:23
tableWidgetItem->setFlags(tableWidgetItem->flags() & (~Qt::ItemIsEditable));

Remove your signal-slot code.

Vidhya
1st August 2012, 06:57
I used another way

Qt::ItemFlags Saleorder::flags( const QModelIndex &index) const
{
Qt::ItemFlags flags = QSqlTableModel::flags(index);
if (index.column() == 9 )
flags &= ~Qt::ItemIsEditable;
return flags;
}


But i need to know.how can i call this method

sonulohani
1st August 2012, 10:45
calling by the method name. I think you dont know the concept of c++.