Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to manually activate CheckBox blue focus indicator ?



  • Hello,

    Working with CheckBox, I am trying to manually activate the blue focus indicator, this one :

    960b6685-55a3-4425-9915-9b0179e3d1d8-image.png

    I see this indicator by pressing tab, but when setting focus property to true this indicator doesn't appear.

    I tried this :

    Window {
        width: 640
        height: 480
        visible: true
    
        Column {
            CheckBox {
                id: chekbox
            }
    
            Button {
                onClicked: {
                    chekbox.focus = true
                }
            }
        }
    }
    

    By pressing the button I correctly having the focus on the checkbox (when I press space the checkbox toggle), but the blue indicator doesn't appear.



  • Problem solved by calling chekbox.forceActiveFocus(Qt.TabFocusReason)



  • Problem solved by calling chekbox.forceActiveFocus(Qt.TabFocusReason)