What if you also call QWidget::setFocus() on a widget in your main window?