QStackedLayout in StackAll mode breaks widget tab ordering
-
I am using Qt 5.15.2 under Fedora 35. I am using QStackedLayout to show a set of application "pages" with the stackingMode set to StackAll. I have to use StackAll as one of the Stacked widgets is using a Video physical Wayland surface and the normal StackOne causes problems as this surface gets deleted/re-created when switching between the stacked widgets.
Generally this is working, but the Widget tabbing order within the stacked widgets gets messed up when I use StackAll rather than StackOne. With the StackAll setting when I TAB through the widgets on the selected "page" widget the focus no longer circles around this widget's focus children, it goes off to somewhere else after the last widget.
Any ideas on what is happening and how to fix this ? -
Some feedback.
Looking through the Qt source code it looks like the QT TAB focus navigation system is pretty crude in QT 5.15.2 and uses QWidget visibility status to work out if the next widget in the TAB sequence should loop back to the first in a parent widget.
If you use a QStackedLayout in StackAll mode QWidgets are raised and lowered not shown and hidden (no visibility change) and so the TAB sequence continues through other widgets which are lowered after the raised one in the QWidgets "shown" in the QStackedLayout.
So basically the QT TAB system does not work properly if you use a QStackedLayout in StackAll mode. It looks like I may be able to override focusNextPrevChild() on my top level QWidgets under the QStackedLayout and get that function to move the focus to first widget in its own list of widgets when TABing beyond the last widget (and handle the previous TAB sequence as well). Might also be able to use some pseudo QWidgets at the start/end of my top level QWidgets children and use the Proxy Focus system somehow.
A bit ugly but it should work for those that need to use a QStackedLayout in StackAll mode.