[Qt] QTabWidget problem

zeljko zeljko at holobit.net
Wed Jan 28 08:42:46 CET 2009

Hi all,

After latest patches about focuspolicy (I've completely removed handling of 
tab & backtab from qt, now LCL controls that part), we have pending problem 
with QTabWidget. QTabWidget::keyPressEvent(QKeyEvent *e) drive us into 
problem since it handles Tab key before that event is passed to LCL, and sets 
focus to tabbar.Original code is here (shorten)
void QTabWidget::keyPressEvent(QKeyEvent *e)
    if (((e->key() == Qt::Key_Tab || e->key() == Qt::Key_Backtab) &&
          count() > 1 && e->modifiers() & Qt::ControlModifier)
                page = 0;
            if (d->tabs->isTabEnabled(page)) {
.... blablablbalbla

        if (!qApp->focusWidget())  <--------- THIS IS PROBLEM
            d->tabs->setFocus();   <--------- THIS IS PROBLEM
    } else {

So, QT always handles tab key at this place, and if qApp->focusWidget() 
returns NULL our focus is jailed into tabbar, and we must use mouse to get 
out of tabbar. That's because we set QtClickFocus on all widgets with 
TabStop=TRUE, and tabbar searches for widget with QtStrongFocus or 

So, in short - we have two solutions:

1.QLCLTabWidget which overrides keyPressEvent().
2.Write completely new TQtTabWidget from stratch.

Den ?


More information about the Qt mailing list