Qt World Summit: Register Today!

Qt:Focus::NoFocus still takes focus

  • I have a keyboard widget that appears when an EditText is focused. I want it to disappear when anywhere other than the EditText is clicked. So I set,


    But, when I click on the Qframe that holds the keyboard, it disappears even though I've set the QFrame to Qt::NoFocus.

    <widget class="QFrame" name="keyboardFrame">
     <property name="focusPolicy">

    I've tried a different approach where I set the parent to Qt::StrongFocus and it's child to Qt:NoFocus, but it seems that the parent Qt::StrongFocus still propagates to its child. Any help would be much appreciated. Thanks!

  • Lifetime Qt Champion

    Not sure why no focus is ignored. Normally it's not.
    Anyway, try to hook a slot to
    and check what it changes to so we are sure it is the
    QFrame that is guilty.

  • Seems like the mainWindow is getting the focus. So, I set the frame to StrongFocus and I can later handle it to keep the keyboard up. However, now, if I have two Qt::StrongFocus objects, mainWindow & QFrame, the mainWindow gets the focus even if the frame is on top. Any way I can change it so the QFrame receives the focus?

Log in to reply