kapoorsudhish
22nd October 2009, 12:33
Hi,
I am new to Qt Environment, i am using a QTablewidget, where i have some some rows and some columns, when the tableWidget was created from QTableWidget, the focus property was set as
tableWidget->setFocusPolicy(Qt::NoFocus );
But still when a cell is clicked on the table, the cell is getting highlighted . Can anyone share as to what can be the reason for the focus not getting cleared from the tableWidget.
Adding the code
{
tableWidget = new QTableWidget(4, 4,RenderScheduleLayout );
QRect rect(40,100,650,200);
tableWidget->setGeometry(rect);
for (int i =0; i < 4; i++)
tableWidget->setColumnWidth(i,50);
for (int i =0; i < 4; i++)
tableWidget->setRowHeight(i,20);
tableWidget->setFocusPolicy(Qt::NoFocus)
connect(tableWidget,SIGNAL(cellClicked(int,int)),t his,SLOT(doSomething(int,int)));
}
void Widget::doSomething(int row, int column){
QTableWidgetItem *newItem = new QTableWidgetItem(tr(""));
newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
tableWidget->setItem(row, column, newItem);
tableWidget->clearFocus();
}
I am also doing a clear focus on this but still the focus on the selected cell is shown, i dont know how to remove the focus as its not being removed using tableWidget->setFocusPolicy(Qt::NoFocus)
Please help me on this issue.
I am new to Qt Environment, i am using a QTablewidget, where i have some some rows and some columns, when the tableWidget was created from QTableWidget, the focus property was set as
tableWidget->setFocusPolicy(Qt::NoFocus );
But still when a cell is clicked on the table, the cell is getting highlighted . Can anyone share as to what can be the reason for the focus not getting cleared from the tableWidget.
Adding the code
{
tableWidget = new QTableWidget(4, 4,RenderScheduleLayout );
QRect rect(40,100,650,200);
tableWidget->setGeometry(rect);
for (int i =0; i < 4; i++)
tableWidget->setColumnWidth(i,50);
for (int i =0; i < 4; i++)
tableWidget->setRowHeight(i,20);
tableWidget->setFocusPolicy(Qt::NoFocus)
connect(tableWidget,SIGNAL(cellClicked(int,int)),t his,SLOT(doSomething(int,int)));
}
void Widget::doSomething(int row, int column){
QTableWidgetItem *newItem = new QTableWidgetItem(tr(""));
newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
tableWidget->setItem(row, column, newItem);
tableWidget->clearFocus();
}
I am also doing a clear focus on this but still the focus on the selected cell is shown, i dont know how to remove the focus as its not being removed using tableWidget->setFocusPolicy(Qt::NoFocus)
Please help me on this issue.