[Qt-interest] [Fwd: [Fwd: AW: [Fwd: [Fwd: Problem with focusNextChild andQPlainTextEdit]]]]
Ian Thomson
Ian.Thomson at iongeo.com
Fri Mar 27 12:22:02 CET 2009
Hi,
> 1. Why if focusNextChild doesn't take care of scaling on parent widget?
> If I press Tab on the last element of a widget, the focus is normally
> recalculated scaling up to parent.
focusNextChild calls focusNextPrevChild(true) and if you look how that
is implemented you will see it does march through the widget's parents
as necessary. However, QAbstractScrollArea handles its scrollable widget
through a viewport, and I am not sure if this is handled by
QPlainTextEdit correctly for the simple reason that pressing the tab
button doesn't (normally) change focus for that widget. I don't know for
sure that this is the case, its just my guess.
> 2. focusNextChild() is protected, so the only solutions seems to be the
> parent subclassing. If the initiative is of Q(Simple)TextEdit, how can
> set focus in general way indipendently from parent?
Passing the focus from the widget should be protected because it's up to
the widget to decide when to do that. It wouldn't make much sense for
another class to tell it to pass its focus to something else. Other
classes can call setFocus if they need the focus.
If you want QSimpleTextEdit to behave differently, then you have to
override it and modify its behaviour. That is the OOP method.
In any case it seems like focusNextChild shouldn't fail for QPlainTextEdit.
Cheers,
Ian.
More information about the Qt-interest-old
mailing list