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. Example of correctly operating C++ model with QML TreeView
Forum Updated to NodeBB v4.3 + New Features

Example of correctly operating C++ model with QML TreeView

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 4.2k Views 2 Watching
  • 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.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by Kofr
    #1

    Hi fiends,
    I am trying to the best of my ability to make QML TreeView to work with C++ model.
    I am cennecting Data Model as C++ class
    qmlRegisterType<TreeModel>("dataModel", 1, 0, "DataModel");

    If you have working example of TreeView working with C++ model such way, please share it.

    p3c0P 1 Reply Last reply
    0
    • K Kofr

      Hi fiends,
      I am trying to the best of my ability to make QML TreeView to work with C++ model.
      I am cennecting Data Model as C++ class
      qmlRegisterType<TreeModel>("dataModel", 1, 0, "DataModel");

      If you have working example of TreeView working with C++ model such way, please share it.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Kofr,
      This example works perfectly with TreeView with some slight modifications like adding roleNames and some changes in data().

      157

      K 1 Reply Last reply
      0
      • p3c0P p3c0

        Hi @Kofr,
        This example works perfectly with TreeView with some slight modifications like adding roleNames and some changes in data().

        K Offline
        K Offline
        Kofr
        wrote on last edited by
        #3

        @p3c0 It is Widgets example. QML QtQuick example is needed

        p3c0P 1 Reply Last reply
        0
        • K Kofr

          @p3c0 It is Widgets example. QML QtQuick example is needed

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @Kofr yes it is. But you can make it work with QML with the changes I mentioned earlier. Just extract the model part and add those changes. It works.

          157

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bowisse
            wrote on last edited by Bowisse
            #5

            And you can get a look here if you need more details :

            http://forum.qt.io/topic/56497/request-treeview-c-model-to-qml-example/2

            1 Reply Last reply
            0

            • Login

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