Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAbstractItemModel for a highly nested data structure
Forum Updated to NodeBB v4.3 + New Features

QAbstractItemModel for a highly nested data structure

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 216 Views 1 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.
  • Ghasem RamezaniG Offline
    Ghasem RamezaniG Offline
    Ghasem Ramezani
    wrote on last edited by Ghasem Ramezani
    #1

    I need a read-only QTreeView model for some highly nested data structures. By nested, I mean something like this:

    struct A 
    {
     int                      _1;
     std::vector<double>      _2;
     std::vector<std::string> _3;
    };
    struct B
    {
     std::vector<A>   _1;
     std::vector<int> _2;
    };
    struct C
    {
     std::vector<A> _1;
     std::vector<B> _2;
    };
    

    Consider having an object per each type and want to visualize it using QTreeView.

    A _1;
    B _2;
    C _3;
    
    MyModel model;
    model.setA(&_1);
    model.setB(&_2);
    model.setC(&_3);
    
    /*
      + A
         ...
      + B
         ...
      + C
         ...
      */
    

    There are more than 50 nested structs. My problem is with those dynamic arrays, and I don't know the efficient way to model them. All I found from examples and LLMs' answers was inefficient in updating the model. They were using beginResetModel() and endResetModel().
    The model is read-only and the structures will be updated every 20ms.

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

      Hi,

      Did you already took a look at the simple tree example ?

      As for your refresh rate, people won't be able to follow them so you might want to consider batching these updates.

      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
      1

      • Login

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