Search code examples
qtqtabwidget

QT: Escape from QTabWidget


I have a dialog and a tab QTabWidget inside it, and inside that tab there is a table view. Please see the screen shot below enter image description here

the problem is when I press tab key from the text box in dialog (text box Telp) it goes to the tab Items and then when I click again it goes to the Table View but I never can get out of this Tab Items. Right now I'm using a QShortcut to escape from this Tab Items and go to the text area on the dialog. I want to use a Tab key to escape from this Tab Items. Is it possible?


Solution

  • OK I can solve this problem by subsclassing QTableView and override keyPressEvent event

    void LMJTableView::keyPressEvent(QKeyEvent *event)
    {
      if(event->key() == Qt::Key_Tab){
        //event->ignore();
        if (nextWidget!=NULL) {
          nextWidget->setFocus();
        }
      }
      else
        QTableView::keyPressEvent(event);
    }