4 ms·
Funny, I'm using the same technique in my block editor[1]. Rather than using the complex table/tree-like data structure of QAbstractItemModel[2], I'm using QAbs
by rubymamis 3y ago
Funny, I'm using the same technique in my block editor[1]. Rather than using the complex table/tree-like data structure of QAbstractItemModel[2], I'm using QAbstractListModel[3] (flat list) with a property called indentLevel[4] for each delegate. It works out great. I still need to manage parent child relationships (it makes rendering changes easier using recursive function) so I keep variables for that, but the "fake tree" look, as I like to call it, simply uses the indentLevel property which is determined by the amount of whitespace/tabs at the start of a line in the underlying plaintext data.
[1] https://www.get-plume.com/ https://www.get-plume.com/
[2] https://doc.qt.io/qt-6/qabstractitemmodel.html https://doc.qt.io/qt-6/qabstractitemmodel.html
[3] https://doc.qt.io/qt-6/qabstractlistmodel.html https://doc.qt.io/qt-6/qabstractlistmodel.html
[4] Q_PROPERTY(unsigned int indentLevel READ indentLevel WRITE setIndentLevel NOTIFY indentLevelChanged)