Hi,
I have reimplemented the keyPressEvent of QLineEdit ( Qt4). Following is the code
{
if(e->key() == Qt::Key_Backtab){
//Do something
}
else if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Tab || e->key() == Qt::Key_Enter){
//Do something
}
else{
}
}
void LineEdit::keyPressEvent(QKeyEvent *e)
{
if(e->key() == Qt::Key_Backtab){
//Do something
}
else if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Tab || e->key() == Qt::Key_Enter){
//Do something
}
else{
QLineEdit::keyPressEvent(e);
}
}
To copy to clipboard, switch view to plain text mode
1. When I press the tab key this part of code is not executed. Another widget which is the part of my application gets the focus (Which should have happened if I wouldn't have reimplemented the keyPressEvent). How can i override this behaviour?
2. Is Qt::KeyBacktab same as Shift+Tab?
3. Can some please show me how to use modifiers. I am trying to use it in the following way :
if(e->key() == Qt::Key_Return && e->modifiers() == Qt::ShiftModifier){
}
if(e->key() == Qt::Key_Return && e->modifiers() == Qt::ShiftModifier){
}
To copy to clipboard, switch view to plain text mode
Is it the correct way of using modifiers?
Thanks a lot.
Bookmarks