1

I need a column in my QTreeWidget which's width is always x pixels.

So i want to capture a resize of my QTreeWidget columns, to set the with back to my x on resize by user. But i can't find any Signal like columnWidthChanged.

Is there any way to call a function/slot when a columns with is changed? Or is there any other solution?

Haselnussstrauch
  • 333
  • 2
  • 10

2 Answers2

2

Instead of connecting to the sectionResized signal and reverting resizes the user made, why not prevent users from resizing the column in the first place, via

treeWidget.header().setSectionResizeMode(QHeaderView::Fixed)

or prevent resizing only individual columns via

treeWidget.header().setSectionResizeMode(colIdx, QHeaderView::Fixed)

That's easier to implement and much more "natural" to the user.

sebastian
  • 9,526
  • 26
  • 54
1

The Signal is emitted by the header of the QTreeWidget. It's QTreeWidget.header().sectionResized(int column, int oldsize, int newsize)

Haselnussstrauch
  • 333
  • 2
  • 10