QAbstractItemModel for a highly nested data structure
-
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
struct
s. 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 usingbeginResetModel()
andendResetModel()
.
The model is read-only and the structures will be updated every 20ms. -
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.