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. Help me choose data model and view layout
QtWS25 Last Chance

Help me choose data model and view layout

Scheduled Pinned Locked Moved QML and Qt Quick
data modelc++ to qml
3 Posts 2 Posters 1.3k 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.
  • S Offline
    S Offline
    sigmaN
    wrote on 5 Oct 2015, 17:10 last edited by
    #1

    I am completely new in QML and Qt Quick.
    I've read some manuals, saw some examples and did my own C++ class with set of parameters(properties) and signals/slots for each parameter change notifications(both from model to view and view to model changes).

    But later i found that QML have data models with delegates and now i am confused. May be i should use them?
    Seems to be my data is not so well suited for using data models, but may be i am not clearly understood them yet..

    My data is a set of device(internal combustion engine control unit) parameters.
    Parameters are: number parameter, array(2D or 3D table), enumeration parameter(choose from list), bitfield parameter(group of checkboxes), string parameter.
    This parameters are grouped by categories and shown in different tabs.

    As i can see, only arrays are well suited for displaying in the grid or list. I have no idea about how to represent rest of parameters.

    It is a good decision to make signal/slot for each parameter(like i did now)?
    Please help me to solve a problem in true Qt Quick way.

    Let me know if my post is incomlete and you need more information about data or whatever..

    P 1 Reply Last reply 7 Oct 2015, 10:38
    0
    • S sigmaN
      5 Oct 2015, 17:10

      I am completely new in QML and Qt Quick.
      I've read some manuals, saw some examples and did my own C++ class with set of parameters(properties) and signals/slots for each parameter change notifications(both from model to view and view to model changes).

      But later i found that QML have data models with delegates and now i am confused. May be i should use them?
      Seems to be my data is not so well suited for using data models, but may be i am not clearly understood them yet..

      My data is a set of device(internal combustion engine control unit) parameters.
      Parameters are: number parameter, array(2D or 3D table), enumeration parameter(choose from list), bitfield parameter(group of checkboxes), string parameter.
      This parameters are grouped by categories and shown in different tabs.

      As i can see, only arrays are well suited for displaying in the grid or list. I have no idea about how to represent rest of parameters.

      It is a good decision to make signal/slot for each parameter(like i did now)?
      Please help me to solve a problem in true Qt Quick way.

      Let me know if my post is incomlete and you need more information about data or whatever..

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 7 Oct 2015, 10:38 last edited by
      #2

      @sigmaN For arrays/list like structures its better to use ListView or GridView as a view. For a model you can use QAbstractItemModel and your already existing C++ logic in it. To make it work with QML have a look at C++ Models with Qt Quick Views.

      enumeration parameter(choose from list)

      For this I think its better to write a separate class with Q_INVOKABLE methods or public slots so as to access them from QML. You will need to embed it into QML. This explains how to do it.

      Now for a view you can use a ComboBox. It accepts a model too. Here you can use a QStringListModel to contain the data. This model can be returned from one of the Q_INVOKABLE methods said above.

      bitfield parameter(group of checkboxes),

      A Q_INVOKABLE method in same class which can return data depending upon say checkbox's for eg. name.

      It is a good decision to make signal/slot for each parameter(like i did now)?

      Normally you would use that in case you want to notify other objects or perform some tasks in non blocking way upon some change. So it depends completely on the requirement.

      157

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sigmaN
        wrote on 9 Oct 2015, 16:55 last edited by
        #3

        Thank you very much! Now it is much more clear for me.

        1 Reply Last reply
        0

        1/3

        5 Oct 2015, 17:10

        • Login

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