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

Qt-interest Archive, January 2008
Wierd behaviour of setResizeMode


Message 1 in thread

Hello all,

I currently have a QTreeView with 3 columns, and I want the 2nd column to
expand when the widget is resized, and the 1st and 3rd column to stay a
fixed size. I have tried the following code:

    header()->setResizeMode(QHeaderView::Fixed);
    header()->setResizeMode(2, QHeaderView::Stretch);

However the last column still stretches (along with the second column) when
the widget is resized. Is this behavior expected as this seems to be a bug
to me.

Thanks
Ryan Winter

--
 [ signature omitted ] 

Message 2 in thread

This is a known (and in the snapshots of 4.3.4 already fixed) bug:

http://trolltech.com/developer/task-tracker/index_html?method=entry&id=190624

4.3.2 didn't have this behaviour, so you might want to switch back to that version, or you can apply this (small) patch: (just move a closing brace one line up)
==== //depot/qt/4.3/src/gui/itemviews/qheaderview.cpp#32 (text) ====

@@ -2846,8 +2846,8 @@
                 if (pixelReminder > 0) {
                     newSectionLength += 1;
                     --pixelReminder;
-                    section_sizes.removeFirst();
                 }
+                section_sizes.removeFirst();
             } else {
                 newSectionLength = section_sizes.front();
                 section_sizes.removeFirst();

> -----Ursprüngliche Nachricht-----
> Von: Ryan Winter [mailto:wintered@xxxxxxxxx] 
> Gesendet: Sonntag, 13. Januar 2008 12:14
> An: qt-interest@xxxxxxxxxxxxx
> Betreff: Wierd behaviour of setResizeMode
> 
> Hello all,
> 
> I currently have a QTreeView with 3 columns, and I want the 
> 2nd column to
> expand when the widget is resized, and the 1st and 3rd column 
> to stay a
> fixed size. I have tried the following code:
> 
>     header()->setResizeMode(QHeaderView::Fixed);
>     header()->setResizeMode(2, QHeaderView::Stretch);
> 
> However the last column still stretches (along with the 
> second column) when
> the widget is resized. Is this behavior expected as this 
> seems to be a bug
> to me.

--
 [ signature omitted ] 

Message 3 in thread

Ryan Winter wrote:
> I currently have a QTreeView with 3 columns, and I want the 2nd column
to expand when the widget is resized,
> and the 1st and 3rd column to stay a fixed size. I have tried the
following code:
>
>    header()->setResizeMode(QHeaderView::Fixed);
>    header()->setResizeMode(2, QHeaderView::Stretch);
>
> However the last column still stretches (along with the second column)
when the widget is resized.
> Is this behavior expected as this seems to be a bug to me.

Note the documentation for QHeaderView::stretchLastSection:
    Note: The horizontal headers provided by QTreeView are configured
with 
    this property set to true, ensuring that the view does not waste any
of 
    the space assigned to it for its header. 

    Also note: If the value is set to true, this property will override
the
    resize mode set on the last section in the header. 

--
 [ signature omitted ] 

Message 4 in thread

Bachrach, Robert L wrote:

> Note the documentation for QHeaderView::stretchLastSection:
>     Note: The horizontal headers provided by QTreeView are configured
> with
>     this property set to true, ensuring that the view does not waste any
> of
>     the space assigned to it for its header.
> 
>     Also note: If the value is set to true, this property will override
> the
>     resize mode set on the last section in the header.

Thanks Robert, I really have no idea how I didn't see this property. Also
your wrapping function your posting application seems really whacked out.

Ryan

--
 [ signature omitted ]