Purpose of FocusScope



  • Hello forum,

    I am trying ton understand the purpose of the Item FocusScope and following the documentation at

    FocusScope

    Could you please run the following snippet at your end?

    import QtQuick 2.0
    
    
    	Rectangle
    	{
    		id: widget
    		color: "lightsteelblue"
    		width: 240
    		height: 25
    		radius: 10
    		antialiasing: true
    
    		Text { id: label; anchors.centerIn: parent }
    		focus: true
    
    		Keys.onPressed:
    		{
    			if(event.key == Qt.Key_A)
                               label.text = 'Key A was pressed'
    			else if(event.key == Qt.Key_B)
    			   label.text = 'Key B was pressed'
    			else if(event.key == Qt.Key_C)
    		           label.text = 'Key C was pressed'
    		}		
    	}	
    
    
    import QtQuick 2.0
    
    
    Rectangle
    {
    	id: window
    	color: "white"
    	width: 240
    	height: 150
    
    
    	Column
    	{
    		anchors.centerIn: parent
    		spacing: 15
    
    		MyWidget
    		{
    			focus: true
    			color: "lightblue"
    		}
    
    		MyWidget
    		{
    			color: "palegreen"
    		}
    	}
    }
    

    The code works as expected without the usage of FocusScope. I am lost here.

    Thanks


Log in to reply
 

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