PDA

View Full Version : How to capture resizing of QTreeWidget columns?



simk
27th April 2006, 06:26
I would like to know if the user resizes the columns of a QTreeWidget, but I can't seem to find a way to do this.

I have tried using the itemPressed/Clicked/etc signals in the QTreeWidget, but clicking the headerItem obviously doesn't cause these signals to be emitted.

I have also tried to capture the mouseRelease events on both the QTreeWidget widget directly, and its viewport, but neither seem receive the Release event when clicking the header.

Does anyone know how I could do this?

munna
27th April 2006, 06:48
I am not sure but i think it can be done in the following way.

In the mousePressEvent you should find which column is being pressed using columnViewportPosition(int column) and probably store the columnWidth somewhere.

In the mouseReleaseEvent you can compare the widths and then emit a signal.

jpn
27th April 2006, 07:10
Connect to signal void QHeaderView::sectionResized(int logicalIndex, int oldSize, int newSize) (http://doc.trolltech.com/4.1/qheaderview.html#sectionResized).
You can obtain the header for the table widget by QTreeView::header() (http://doc.trolltech.com/4.1/qtreeview.html#header).