PDA

View Full Version : Unable to get the correct QWidget width after expansion



sajaskk
10th June 2013, 07:41
I am trying to embed a Qtreeview inside a QWidget. The user has the choice of expanding the QWidget. The width of the columns in the Qtreeview are calculated based on the current QWidget width. There are 5 columns in the treeview. Each column takes a fraction of the total QWidget width. I am using QWidget::width() function to get the current width of the widget. But even after expansion of the widget I am getting a constant number(100) as the QWidget width. I have also used SetStretchLastSection.

Illustration of the problem is as follows:

Normal Treeview Widget:
9133

After Expansion:

Expected Behaviour:
9134

Current Behaviour:
9135

anda_skoa
10th June 2013, 07:52
Wouldn't it be easier to just set the resize mode for the second column to Stretch?

Cheers,
_

sajaskk
10th June 2013, 08:05
I tried that. But the other columns should have their resize mode set to interactive. So, if I set the second column's resize mode as stretch, columns after it gets expanded in the opposite direction.

anda_skoa
10th June 2013, 15:49
Ok, I'll probably don't fully understand your objectives.
But why do you use the parent widget's width and not that of the treeview itself?

Cheers,
_