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

How to set default focus properties on priority?



  • I want to have a default focus on a QLineEdit when there is any state transition is happening during runtime and when coming back to main window.
    For example, I have QLineEdit as a text input field and in that window I have QTVirtualKeyboard which is always capsLockActive and Shift button is disabled, whenever there is a state transition and coming back to main window which is having QTVirtualKeyboard then Focus is coming back to main window and in Code i do setFocus() on QLineEdit & cursor starts blinking but still Shift button remains enabled untill user clicks on QLineEdit text field.
    Please share how do I make Shift button disabled in the start before clicking anywhere when entering into this state? I have placed setFocus and Shift button disabled call as below in my code at multiple places including constructor, but nothing is working for this scenario.

    QTimer::singleShot(0, QLineEdit, SLOT(setFocus()));
    QMetaObject::invokeMethod(m_GUI->getVirtualKeyboard()->rootObject(), "capLockActive", Q_ARG( QVariant, QVariant(true) ) );

    Thanks in advance for any advice.



  • Hi,
    We want to have capsLockActive and shift key disabled for qml virtual keyboard in our C++ Qt based application where we are using QML virtual keyboard. We are using Qt 5.13.2.
    We have called below function at multiple places in our code, but still, we are not able to get consistent behaviour for shift key disabled.

    And when user clicks on shift key multiple times, our application gets crashed, that is very critical situation for our product.

    QTimer::singleShot(0, QLineEdit, SLOT(setFocus()));
    QMetaObject::invokeMethod(m_GUI->getVirtualKeyboard()->rootObject(), "capLockActive", Q_ARG( QVariant, QVariant(true) ) );
    Please help with the consistent way to keep capsLock active and disable shift key for virtual qml keyboard.

    Attached are the images with shift key enabled and disabled. we need our keyboard with shift key disabled all the time.


Log in to reply