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:
Treeview 1.png

After Expansion:

Expected Behaviour:
Treeview 2.png

Current Behaviour:
Treeview 3.png