View Full Version : QTreeView/QHeaderView : resize handle on the left

14th May 2009, 16:42
Hi !

Here is what I am trying to do: I have a QTreeView with two columns. The first one is the important one, the second one the not-so-important one. I'd like to have my first column automatically resized when the treeView is resized and the second one to be resizable by hand.

items = new QTreeView();
QHeaderView * header = items->header();
header->setResizeMode(0, QHeaderView::Stretch);
header->setResizeMode(1, QHeaderView::Interactive);

The issue is that the zone I have to click on to resize a column is on the right. The QTreeView being on the right edge of the window, clicking on the column separator at the end of the last column becomes quite a challenge, and the movement is not intuitive (you have to move the cursor out of the window to the right to have the left side of the column move to the left). I'd like to be able to resize the last column by clicking on the separator present between the two columns.

Is it possible to move the resize handle on the left side of the column ? Is there a better way to do that ?

Thanks in advance

14th May 2009, 18:03
I dont know if it might work, but you can try this -
Get the status bar and change its layout direction :)

14th May 2009, 21:43
Unfortunately, it just doesn't quite do the trick :)
Even though the "resize zone" is moved on the left, the whole widget has its layout switched to Qt::RightToLeft. It induces very weird behaviors of the widgets.

If anyone else has a better option, I'm more than willing to consider it, but it looks like I'll have to just forget about it :/

14th May 2009, 23:43
You can attach to the sectionResized() signal of QHeaderView and do the proper resizing yourself. You'll have to detach the header from resizing the view of course.