The same way you probably already did it: self.ReqTree = QtWidgets.QTreeWidget, except that now you need two of them, one for each tab.How do I add tree widget pointers in Python ?
I don't know what the data is that you are displaying in your tree widget. I assume it is some hierarchical data because you chose a tree to display it. I also assume that, based on the combo box selection, you are only displaying part of the data in the tree, not all of the data.Make a method that returns you the correct part of the data structure based on the combo box selection.
I am not that good at Python, but a Python list seems like one way to construct a tree-shaped data structure. A list containing lists, which contain lists, and so on. So say your top-level list has five items in it, and the combo box is used to choose one of those five items. You then want to display the list hierarchy that starts with that item.
You have two ways to find that place in the top-level list. If the top-level list items are the same strings you put in the combo box, then it is easy - you just look at each item in the top-level list until you find the match. If the strings in the combo box are not in the list, then you can use the alternative signal from the combo box, the one that returns the integer index of the item that was selected. Using that index, you get the top-level list item at that location.
Qt Code:
theList = [[A, [Aa, [a_i, a_ii, a_iii], [a_iv, a_v, a_vi], [a_vii, a_viii, a_ix], ...], [b, [b_i, b_ii], [b_iii, b_iv, b_v]], ...], [B, [Bb, [...]]], ...]To copy to clipboard, switch view to plain text mode
theList at index 0 gives you [A, [Aa, [a_i ...]]] and you build your tree widget items starting there.
You might be using a different data structure, but the idea is the same - find a way to locate the place you want based on the combo box selection, and use that to build the tree.
Bookmarks