1

My program, gets a list from a webpage using QNetworkAccessManager like this:

<div>
    <ul>
        <li>a1
            <ul>
                <li>a2
                    <ul>
                        <li>a3
                        </li>
                        <li>a4
                            <ul>
                                <li>a5
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li>a6
                </li>
            </ul>
        </li>
    </ul>
</div>

What is the best way to make a QAbstractItemModel for a QTreeView like QFileSystemModel from that list?

Saj Haz
  • 123
  • 1
  • 10
  • 1
    Use `QDomDocument` do parse the text, and recursively iterate through the DOM to get the tree. Then either create your own model for it, or just use `QStandardItemModel` (it has the downside of not being very fast or space-efficent, but that only matters if you have a lot of data). – hyde Jan 30 '16 at 10:49
  • Your question is kinda broad too, you seem to be asking for Qt model-view tutorial, basically... Here's a possible duplicate: http://stackoverflow.com/questions/4354515/qabstractitemmodel-and-qtreeview – hyde Jan 30 '16 at 10:56
  • I know, but I thought might be an easier way is available or a class is ready to do it. Thanks, however. – Saj Haz Jan 30 '16 at 16:42
  • @SajHaz. If the html is valid xml, you should be able to adapt the code in [this answer](http://stackoverflow.com/a/8840565/984421) to do what you want. – ekhumoro Jan 30 '16 at 19:00

0 Answers0