Transfer focus to SwipeView inner element
-
Hi all. What i am trying to achieve: I have custom QML component
CustomElemwith SwipeView inside. SwipeView by itself can contain different components inside and i want to transfer focus to one of them whenCustomElemcomponent take focus.For example:
main.qmlloaded --> user push button and one ofCustomEleminmain.qmlbecomes 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
RectangleactiveFocusproperty becomestrue.I have QML component
CustomElem.qmlwith 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.qmlas 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
-
Hi all. What i am trying to achieve: I have custom QML component
CustomElemwith SwipeView inside. SwipeView by itself can contain different components inside and i want to transfer focus to one of them whenCustomElemcomponent take focus.For example:
main.qmlloaded --> user push button and one ofCustomEleminmain.qmlbecomes 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
RectangleactiveFocusproperty becomestrue.I have QML component
CustomElem.qmlwith 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.qmlas 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 } }@egor.utsov
Maybe this post would help?
https://forum.qt.io/topic/93347/focus-issue-in-swipeview-with-loader -
Hello,
I have very similar problem. Did you find any solution?
poor_robert
@poor_robert Hi! I used
KeyNavigation.down: swipe.currentItemin the element rootItem. But i think it is the same asforceActiveFocus.