Dynamic access to QML elements from QML



  • Hello!

    Is there any way to have "n" TextInputs/TextEdits, and dynamically access them from another object? For example by their objectNames (I know that it is possible to do from Cpp, but I haven't found any method to do this in QML).

    Thanks in advance

    P.S. The need came out from an idea to use custom global keyboard, that can be set visible or not. But to make this keyboard work, I have to make dynamic match between actually clicked object (text input) and the global keyboard.


  • Moderators

    @monster You can create the TextInput using createComponent and then after creating its object you can assign it to a js variable. You can store them for eg. in an array for further reference.

    var component = Qt.createComponent("MyTextInput.qml");
    var textinput = component.createObject(parent);
    


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