Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, December 2006
TreeWidget column width


Message 1 in thread

Hi,
 
I have three columns in my QTreeWidget. I want width of first one to
keep expanding, whereas width of 2nd and 3rd to be fixed. The header in
my Tree Widget is hidden so user can never change the width.
I write following code:
 
_ui->treeWidget->header()->setResizeMode(0,QHeaderView::Stretch);

_ui->treeWidget->header()->setResizeMode(1,QHeaderView::Interactive);

_ui->treeWidget->header()->setResizeMode(2,QHeaderView::Interactive);

_ui->treeWidget->header()->resizeSection(1, 40);

_ui->treeWidget->header()->resizeSection(2, 40);

What I expect is the First column take all extra space except 40+40 from
the Column 2 and Column3, but the result is not so.

Can any one please tell me how to "make width of first column to keep
expanding, whereas width of 2nd and 3rd to be fixed"

Thanks.

 

 

 


Message 2 in thread

Hi

You should try overloading the forms resizeEvent() and set the column
widths there.

Doing that works for me anyway...

Regards

Tim

On 12/22/06, Jaya Meghani <Jaya.Meghani@xxxxxxxxxx> wrote:
>
>
> Hi,
>
> I have three columns in my QTreeWidget. I want width of first one to keep
> expanding, whereas width of 2nd and 3rd to be fixed. The header in my Tree
> Widget is hidden so user can never change the width.
> I write following code:
>
>
>
> _ui->treeWidget->header()->setResizeMode(0,QHeaderView::Stretch);
>
> _ui->treeWidget->header()->setResizeMode(1,QHeaderView::Interactive);
>
> _ui->treeWidget->header()->setResizeMode(2,QHeaderView::Interactive);
>
> _ui->treeWidget->header()->resizeSection(1, 40);
>
>
> _ui->treeWidget->header()->resizeSection(2, 40);
>
> What I expect is the First column take all extra space except 40+40 from the
> Column 2 and Column3, but the result is not so.
>
> Can any one please tell me how to "make width of first column to keep
> expanding, whereas width of 2nd and 3rd to be fixed"
>
> Thanks.
>
>
>
>
>
>


-- 
 [ signature omitted ] 

Message 3 in thread

Hi,
 
I have three columns in my QTreeWidget. I want width of first one to
keep expanding, whereas width of 2nd and 3rd to be fixed. The header in
my Tree Widget is hidden so user can never change the width.
I write following code:
 
_ui->treeWidget->header()->setResizeMode(0,QHeaderView::Stretch);

_ui->treeWidget->header()->setResizeMode(1,QHeaderView::Interactive);

_ui->treeWidget->header()->setResizeMode(2,QHeaderView::Interactive);

_ui->treeWidget->header()->resizeSection(1, 40);

_ui->treeWidget->header()->resizeSection(2, 40);

What I expect is the First column take all extra space except 40+40 from
the Column 2 and Column3, but the result is not so.

Can any one please tell me how to "make width of first column to keep
expanding, whereas width of 2nd and 3rd to be fixed"

Thanks. 

P.S. Hope you all had a wonderful Christmas and wish you a Happy New
Year!