Unsolved Transfer focus to SwipeView inner element
-
Hi all. What i am trying to achieve: I have custom QML component
CustomElem
with SwipeView inside. SwipeView by itself can contain different components inside and i want to transfer focus to one of them whenCustomElem
component take focus.For example:
main.qml
loaded --> user push button and one ofCustomElem
inmain.qml
becomes focused (elem.focus = true
) --> focus is transferred through object hierarchy insideCustomElem
, through SwipeView down to element inside the SwipeView, that have propertyfocus: true
.In my example i want that inner
Rectangle
activeFocus
property becomestrue
.I have QML component
CustomElem.qml
with following code:import QtQuick 2.0 import QtQuick.Controls 2.2 Item { id: rootItem objectName: "rootItem" width: parent.width height: parent.height SwipeView { anchors.fill: parent objectName: "swipeView" Rectangle { id: innerRect objectName: "rectInRect" focus: true color: activeFocus ? "orange" : "black" } } }
This component used in
main.qml
as followed:import QtQuick 2.9 import QtQuick.Window 2.2 Window { objectName: "window" visible: true width: 640 height: 480 title: qsTr("Hello World") Item { id: keyHandler objectName: "keyHandler" } CustomElem { width: 200 height: 200 focus: true } CustomElem { width: 200 height: 200 y: 200 } }
-
Hello,
I have very similar problem. Did you find any solution?
poor_robert
-
@egor.utsov
Maybe this post would help?
https://forum.qt.io/topic/93347/focus-issue-in-swipeview-with-loader -
@poor_robert Hi! I used
KeyNavigation.down: swipe.currentItem
in the element rootItem
. But i think it is the same asforceActiveFocus
.