Hi All,<br><br>I'm a new bie to Python and I'm developing an application where in I created a tree view with checkboxes and associated the view/model to a combo box. <br><br>Treeview code:<br><br>class StdItemModel(QStandardItemModel):<br>
def __init__(self, parent = None):<br> super(StdItemModel, self).__init__(parent)<br> <br>class CheckBoxTreeView(QTreeView):<br> def __init__(self, parent = None):<br> super(CheckBoxTreeView, self).__init__(parent)<br>
self.mylist = ['STB1','STB2','STB3','STB4','STB5','STB6','STB7','STB8']<br> self.MainUI()<br> <br> def MainUI(self):<br> self.stdmodel = StdItemModel()<br>
for val in self.mylist:<br> item = QStandardItem(val)<br> item.setCheckable(True)<br> self.stdmodel.appendRow([item]) <br> self.setModel(self.stdmodel) # Add Elements<br>
<br>This created a tree view of checkboxes. but at the top I see "1" not sure how do I replace that with STB and I want the tree view to be collapsable. How do I acheive that ?<br><br>when I associate this with the combobox, this tree view is visible inside the combo box but only one of the checkbox is selectable. where are when I run the treeview seperately, I can check multiple check boxes. Am I missing something here? <br>
<br>This is how I associated the tree view to a combo box:<br><br> stb_combobox = QComboBox()<br> cbtv = CheckBoxTreeView()<br> stb_combobox.setView(cbtv)<br> stb_combobox.setModel(cbtv.stdmodel)<br>
<br><br clear="all"><br>-- <br>Vijay Swaminathan<br>