Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
What is focus in qml?
Hello , I am a beginner in qml, and may i know the focus term. I have a simple example here:
import QtQuick 2.6
import QtQuick.Window 2.2
width: 50;height: 50
width: 50; height: 50
Though i set the focus to red rectangle, i can see blue rectangle when i run this.
Here are two overlapping rectangles and I would like to do it as: when user clicks on the window, the focus should change to red rectangle and see red rectangle. It would be nice someone helps in this simple example.
The "focus" property refers to Keyboard focus (http://doc.qt.io/qt-5/qtquick-input-focus.html).
What happens in your example is that the red rectangle is painted and the blue rectangle is then painted on top of that.
What you can do is use a MouseArea to react to the mouse click and then toggle the "visible" property of the rectangles in the onClick handler.
@Ilja Cant i do anything using focus property?
@JennyAug13 You can, but it is not used for showing or not showing GUI elements. The focus property is used for capturing keyboard input focus.
Is that possible for mouse press or drag input status also?