ranna
20th March 2009, 11:47
Hi,
I have implemented the keypress event for QTableView and it is working file with enter key. i have reused the eventFilter() function of the QObject.
void ClassXyz::eventFilter(QObject *recv, QEvent *event)
{
if(recv=tableview)
{
if(event->type() == QEvent::KeyPress)
{
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
if(ke->type() == Qt::Key_Tab)
{
//my own operation, move to next cell
}
}
}
else
{
//call QObject's eventFilter
}
}
the above code, says that if i press a tab key in a table view cell's "my own operation-cursor willl move next" has to be executed.
Case 1:
The problem is the eventFilter is not always called if i press the tab key when the cursor is in the cell (cell is in edit mode). i.e i have entered a data in a cell and if i press the tab key, no eventFilter is called and the cursor is not moving to next cell. Instead datachanged signal of the tableview is triggered.
Case 2:
But i have selected the cell (just a single click) and press tab key then the eventFilter function is called and the cursor is moving to next cell with display role.
please tell me what will be problem. it is required for me to resolve the case1.
Thanks
ranna
I have implemented the keypress event for QTableView and it is working file with enter key. i have reused the eventFilter() function of the QObject.
void ClassXyz::eventFilter(QObject *recv, QEvent *event)
{
if(recv=tableview)
{
if(event->type() == QEvent::KeyPress)
{
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
if(ke->type() == Qt::Key_Tab)
{
//my own operation, move to next cell
}
}
}
else
{
//call QObject's eventFilter
}
}
the above code, says that if i press a tab key in a table view cell's "my own operation-cursor willl move next" has to be executed.
Case 1:
The problem is the eventFilter is not always called if i press the tab key when the cursor is in the cell (cell is in edit mode). i.e i have entered a data in a cell and if i press the tab key, no eventFilter is called and the cursor is not moving to next cell. Instead datachanged signal of the tableview is triggered.
Case 2:
But i have selected the cell (just a single click) and press tab key then the eventFilter function is called and the cursor is moving to next cell with display role.
please tell me what will be problem. it is required for me to resolve the case1.
Thanks
ranna