Search code examples
qmlqtquickcontrols2

SwipeView's key handler preempting key handler of a child


I'm using QtQuick.Controls 2.0 TabBar to control a SwipeView. By default, TabBar and SwipeView respond to the left and right arrow keys, using what I assume is an onPressed handler.

As far as I can tell, these default key handlers are undocumented.

I need a certain element in my UI to get events for all four arrow keys when and only when it has active focus. Currently it does so through an onReleased handler, but whenever the ancestor SwipeView responds to a key, the child element does not receive the expected onReleased key event.

I don't object to the SwipeView's default behavior, but I want my behavior to take priority. How can I do it?


Solution

  • By changing the onReleased handler to onPressed. If there was ever a good reason for that handler to be onReleased instead of the more commonly used onPressed, it is no longer evident.