Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-44630

Wrong focus after show new MDI window and after switch between MDI windows.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.3.1
    • GUI: Window management
    • None
    • Windows 7 Home 64bit

    Description

      [[What I do]]
      I create window in Qt Desinger add few QLineEdit with labels and arrange them in specific tab order for it. Then I change ancestor for that window to QMdiSubWindow. Then (in MainWindow) I add menu item "Add subwindow" and slot for it. I added QMdiArea as the main widget to MainWindow too.

      [[What is wrong]]
      When I run my application and click "Add subwindow" then window appears but focus is not set to the first line edit. Focus is set to some unknow item. And it is required to hit Tab key in order to set focus to first item. When I create second window and switch between windows (with Ctrl+Tab key) then focus is lost again (every time after switching). This is very anoying...

      [[What should be]]
      After show new MDI subwindow it should set focus to the first item on the focus list (item with number "1" in Qt Desinger when I edit tab order). And after window switching it should restore proper focus for that window (it is not neccessary first item in tab order because user can switch focus to the next item in the order list (in middle time).

      [[My example of this bug]]
      I attached minimal application which shows this wrong behaviour.

      [[Woraround]]
      Solution for that bug I found in this bug report: https://bugreports.qt.io/browse/QTBUG-23515 . I Wrote this bug report because the linked report does not mention about lost focus after MDI window show. Note that in order to workaround this bug entirely you must (in addition to linked workaround) add to your MDI windows constructors line like that:
      lastFocusedWidget = ui->lineEdit1;
      Where lineEdit1 is your first item on the tab order list. This cause set proper focus to the first item.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            szyk Szyk
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes