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

Populating a QComboBox and a QTable[View|Widget] from javascript



  • Hi guys!

    I'm trying to write a script for an application developed in Qt, using javascript for the business logic and a .ui file for the GUI, but I'm facing two problems.

    In the ui I declared a QComboBox, to which I successfully connect javascript functions to handle signals such as editTextChanged, etc. I was wondering I cannot populate the combobox from within javascript code, because the addItem function is not exposed to script-side code.

    @
    combobox.editTextChangedaction; // OK (action is "connect" or "disconnect")
    combobox.addItem("element 1"); // Error!
    @
    Is there any (other) way to do this?

    I need to show a set of items (strings) in a table-like component. I tried using a QTableView and QTableWidget but I cannot insert or get items. For example, from javascript I cannot access the setModel function of a QTableView (if at least I could create a QAbstractItemModel from script...), neither I can access the item(row,col) function of a QTableWidget class, to set an item's text. Is there any way to show a table of strings to the user, let edit them and retrieve the modified contents?

    Thanks in advance.
    Antonio


Log in to reply