8
votes

I am using a QTreeWidget to display items in categories. Items will use several columns, but I want categories (ie. root items) to use the full width of the widget.

How can I do that?

And a piece of my code:

class BugsList(QtGui.QDialog):
    def __init__(self, parent, reports):
        super(BugsList, self).__init__(parent) # Call QDialog constructor
        self._tree = QtGui.QTreeWidget(self)
        self._tree.setColumnCount(NUMBER_OF_COLUMNS)
        # ...
        for category, bugs in reports:
            category_widget = QtGui.QTreeWidgetItem(self._tree, [category])
            # ...

Here is a screenshot of the current state of my application: screenshot

1

1 Answers

7
votes

Fixed with using QTreeWidgetItem::setFirstColumnSpanned.