Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Purpose of FocusScope
Forum Updated to NodeBB v4.3 + New Features

Purpose of FocusScope

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 286 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sajis997S Offline
    sajis997S Offline
    sajis997
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved