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?
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.