[Development] Why isn't FocusScope a property on Item?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Mon Feb 24 10:03:58 CET 2020


Hi,

Something that I've always wondered about (and hopefully whose reasons 
have been lost in the Nokia times) is why FocusScope exists a dedicated 
item, rather than simply being an ordinary property on Item?

Any custom QQuickItem subclass can be a FocusScope, it just needs to set 
a flag on itself. Why is the flag something only toggable from C++, 
rather than being a Q_PROPERTY?


The *entire* implementation of FocusScope is exactly what one may think:

> QQuickFocusScope::QQuickFocusScope(QQuickItem *parent)
> : QQuickItem(parent)
> {
>     setFlag(ItemIsFocusScope);
> }


What's the problem with this? It's just that one needing a focus scope 
in QML needs to introduce a new element in the tree. That is *super* 
annoying: it messes up sizing / anchoring, requires aliasing properties 
from FocusScope's contents, and so on.

So, does anyone know the historical reasoning here, or any good reason 
for not changing FocusScope just a normal property on Item?



(Note: I'm not opening the problem about whether a component/top level 
item in a QML file isn't automatically a focus scope -- that would lead 
to "interesting" complications of the language.)

Thanks,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200224/0000718e/attachment-0001.bin>


More information about the Development mailing list