How to create a TreeView with Qt and Go?

Viewed 40

I'm trying to make a Qt TreeView for my application, I'd been using a ListView originally but I think a treeview would suit my needs better however the documentation is almost none existent.

to add a new item to a listview is use

var list = QNewListWidget(nil)
list.AddItem2("Sample")

however I've been looking to change it to a treeview so I can have:

Sample
 - Sample child 1
 - sample child 2

The documentation almost seems no existent for Go, anyone know how I can do this ?

1 Answers

For anyone wondering, I finally worked it out. You have to add an invisible item and add your parent items as a child to that:

list_item := widgets.NewQTreeWidgetItem2([]string{"Sample Item"}, 0)
root := pointsOfInterest.InvisibleRootItem()

root.AddChild(list_item)

child_list_item := widgets.NewQTreeWidgetItem2([]string{"Child item"}, 0)
list_item.AddChild(child_list_item)
Related