Beginner question: Model for a simple form?



  • My problem is a very typical one:
    I have a class in my backend, and need to make a form, where I do the data entry. For simplicity, lets assume, the model would consist of the folowing variables:

    string sampleInfo;
    string sampleCode;
    string volume;
    
    

    In reality, my model would contain more variables. What is the best way to update my backend class from qml? I don't want any Qt code in my backend class. Does it make sense to use an AbstractItemModel even if I will always only have one entry (I will never have a list of samples)? Also, is it even possible to use an abstractitemmodel outside of a listview?

    Or would it be better to make QObject derived wrapper class where I expose the variables as properties?

    Or other suggestions?


  • Lifetime Qt Champion

    Hi,

    It looks a bit like overkill to have a full model implementation for one object. Having a QObject wrapper makes more sense.


Log in to reply
 

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