Seeking suggestions on a form that allow users to pass coding to the application



  • Hi everyone,

    I am thinking of developing a form that allow users to define variables, set up conditions, design iterations, and output to predefined variables. This whole input is then passed to the coding and becomes part of the coding of the application. It is like a template that allow a user that is not familiar with c++ can write relatively complex functions. It is like a super calculator that allow the use to code within the given structure.

    It would be amazing if I could do this? Please help and thanks to everyone. :)


  • Moderators

    @pdsc_dy If it does not have to be C++ you can take a look at http://doc.qt.io/qt-5/topics-scripting.html (JavaScript).



  • @jsulm Thanks a lot. The program is in C++ but I can use it with Qt script. Thanks for the tips. Let me read the documentation and I hope you don't mind if I have some more questions.



  • @jsulm, I went through the documentation. Are you referring to QML? Can you be more specific? Thanks.


  • Qt Champions 2016

    @pdsc_dy
    Hi
    You got QScript with is an older scripting tech. Its very solid but no longer maintained. javascript.

    Then you got QML.
    Its the language of the Mobile generation and allows to build GUI too. It can also contain javascript and you can
    make it possible for user to define new functions etc and run it from c++. In c++ you can read values and such. Values can also be
    accessible to the QML part. You can even allow users to define new GUI for a function if you want so it can accept user input
    by itself. Its very dynamic.

    http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html



  • @mrjj, Thank you for your advice. Alternatively, is it possible for me to generate the functions using user's input and dump them in a library or resource file? In this case, I think I need to have two sub projects. The first one needs to be compiled and run to populate the libraries, and the second one use the libraries to finish up the run. By doing that would I avoid embedding the QML graphics in the widgets, which seems to be hard? Thanks!


  • Qt Champions 2016

    @pdsc_dy

    Hi

    • dump them in a library or resource file

    Since you will be using javascript. Its just pure text files and need no compilation so it would be easy
    to save to file and use as lib.

    Note that QML is not compiled. it can run as it.
    So user can make a js function and the c++ app can run it.

    import QtQuick 2.0
    
    Item {
    
        function someUserFunc(Obj) {
            var len = Obj.Variables.length;
            for (var i = 0;i < len; i++) {
                var c=Obj.Variables[i];
               ...
            }
    }
    


  • @mrjj

    Thanks! I went through the QML / quick documentation and tried out some examples. There is quite a bit to learn but it seems very flexible. My main confusion is how to use QML/Quick from QWidget. I will need to include the merge the quick forms with widgets, and use the input from quick forms to populate a library. This may not be a fair question as it seems quite general. Can you point me to some documentation for this? Also do I have to use JS? Is it possible to use subproject and have the earlier sub project generate and compile the library first, and use it later for the main calculation, all using c++ and widgets, without using QML? Thanks again for taking the time to help me.


  • Qt Champions 2016

    @pdsc_dy
    Hi
    If you dont use js/QML, then you would need to supply a compiler with your app to
    compile the user functions to a dll or something like that.
    Will get pretty complex fast.



  • @mrjj Got it. Thanks a lot!


Log in to reply
 

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