[Qt-interest] Focus handling related info
Girish Ramakrishnan
girish at forwardbias.in
Tue Sep 1 19:33:47 CEST 2009
manish.s.sharma at nokia.com wrote:
> Hi All,
>
> Need some information related to focus handling inside a QWidget derived
> components. Where can I find the code for the focus handling inside Qt
> source code. For example implementation of rules like:
> - If it is a shortcut button don’t transfer the focus to the button.
>
Shortcuts are stored in a map (qshortcutmap.cpp). Before sending key
press events to widgets, QApplication would check if there is a shortcut
associated with key event (search for shortcutMap in qapplication.cpp).
If there is a shortcut, ShortcutEvent is sent, otherwise it lands up as
a key event. The actual focus transfer for shortcuts is done by the
widgets themselves (by calling setFocus) - see the code in buttons,
labels, for example.
If you want to dig deeper, the actual translation of platform key events
to Qt key events happens in qkeymapper*, but i have to warn you that
code is not for the weak hearted.
> There should be some component which actually decides where the focus
> should go. For example in QGraphicsView architecture this focus transfer
> is done by QGrahicsScene. Is there any similar thing in Qwidget type
> widgets?
>
Focus transfer can happen in many cases: when a shortcut is pressed (see
the widget code), mouse, keyboard tabs, setFocus is explicity called,
buddy, focus proxy. What are you looking for :)?
Girish
More information about the Qt-interest-old
mailing list