Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Beginner question: Model for a simple form?

Beginner question: Model for a simple form?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 194 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved