PDA

View Full Version : QTreeWidget Column Resize Everywhere



Alundra
2nd November 2014, 03:51
Hi all,
Using a QTreeWidget with 2 columns it's possible to resize the column to see more of less of it's content.
I would know if it's possible to hide the column names but still be possible to resize them everywhere when you are on a separation of two columns.
Here a picture to show what is wanted : https://docs.unrealengine.com/latest/images/Engine/Actors/Transform/UserDefinedArrays.jpg
You can see the line separator, everywhere you are on it, you can resize to see more or less the name of the property.
Thanks for the help

wysota
2nd November 2014, 10:06
It is possible if you implement it. You should handle mouse events in the view, detect a situation when you grab the separator and drag it around and resize columns accordingly.

Alundra
2nd November 2014, 13:49
Is it the correct way doing that in mouse move event to detect intersection ?

for( int i = 0; i < header()->count(); ++i )
{
// Only visible sections starting from second column.
if( header()->isSectionHidden( i ) || header()->visualIndex( i ) <= 0 )
continue;

// Position mapped to viewport.
int pos = header()->sectionViewportPosition( i ) - 1;
if( pos > 0 )
{
//Test intersect with mouse pos mapped to viewport, x-value + margin.
}
}

wysota
4th November 2014, 09:55
This code doesn't do much so it is hard to say whether this is "correct" or not. For instance I can't see any code for determining where the mouse cursor with regards to the columns.