Getting keyboard focus with TabView



  • I'm trying to get the keyboard focus inside a tab. What am I doing wrong?

    @import QtQuick 2.2
    import QtQuick.Controls 1.1

    ApplicationWindow {
    id: main
    visible: true
    width: 640
    height: 480
    TabView {
    id: tabView
    anchors.fill: parent
    focus: true //tabview inherits focusscope, so we should probably set focus to true
    Tab {
    //broken
    Rectangle{
    color:'red'
    focus: true;
    Timer { repeat:true; interval: 1000; running: true; onTriggered: {console.log("Focus: "+parent.focus+" activeFocus: "+parent.activeFocus);}}
    }
    }
    }
    //works!
    // Rectangle{
    // anchors.fill: parent
    // color:'red'
    // focus: true;
    // Timer { repeat:true; interval: 1000; running: true; onTriggered: {console.log("Focus: "+parent.focus+" activeFocus: "+parent.activeFocus);}}
    // }
    }@

    For me, this prints "Focus: true activeFocus: false" once a second, how do I get activeFocus to be true as well?



  • I managed to get activeFocus by using forceActiveFocus().


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.