[Qt-components] Key navigation

Alan Alpert 416365416c at gmail.com
Tue Jan 8 16:52:51 CET 2013

On Tue, Jan 8, 2013 at 7:47 AM, Alberto Mardegan
<mardy at users.sourceforge.net> wrote:
> On 01/08/2013 04:00 PM, Alan Alpert wrote:
>> http://qt-project.org/doc/qt-5.0/qtquick/qtquick-input-focus.html#acquiring-focus-and-focus-scopes
>> It shows a component that is practically a button. It too has only one
>> focusable item. But when used as a component, the two objects with
>> "focus: true" lead to a confusing result in the main file. I assume
>> the same would happen with Button:
>> Button { id: button1; focus: true }
>> Button { id: button2: }
>> So without a FocusScope on button, you just end up with two MouseAreas
>> with focus == true and the 2nd button is likely to start with the
>> keyboard focus.
> I see. The way that keyboard focus is handled in QML is actually very
> confusing; in practice, the "focus: true" property acts both as a
> "canFocus: true" flag and as a "setFocus()" method.
> The problem in the example above only occurs if the "Button" component
> implementation has a "focus: true" property; otherwise, it works fine.
> So, following your initial suggestion, I understand that we don't need a
> "canFocus" property because a focusable item is either a FocusScope or
> an item with "focus" set to "true". Correct?

Correct. And with components it seems better to make it a FocusScope.

Alan Alpert

More information about the Qt-components mailing list