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

Setting focus on invisible items leads to inconsistent behaviour

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P4: Low
    • None
    • 4.7.2
    • Widgets: GraphicsView
    • None

    Description

      While investigating QTBUG-14716 I noticed that invisible items can gain focus in QGraphicsItem::setFocusHelper but cannot gain focus in QGraphicsScene::setFocusItemHelper. This means that trying to set focus on an invisible item leads to the situation where the item believes that it has focus but the scene does not think there is a focused item (so key events go nowhere). A simple patch to rectify the inconsistency is attached, but it's possible that the problem is not in setting subFocus internally but in returning the item in QGraphicsItem::focusItem() despite not being visible. (also, in this instance the item doesn't gain focus when it becomes visible, somewhat inconsistent with the setFocus docs).

      This problem can be seen in the Samegame demo (only within qtdemo, presumably due to the extra focus scope) before the commit that fixes QTBUG-14716 (which works around this problem by only setting focus once the TextInput is visible). QDeclarativeItem::activeFocus is true on the TextInput because focusItem() called on the object says that it has focus, but the scene focus item is null (leading to no key events being delivered).

      Attachments

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

        Activity

          People

            smd Jan Arve
            aalpert-nokia Alan Alpert (closed Nokia identity) (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes