QTreeWidget and column width

1,342 views
Skip to first unread message

Luigi Ferraris

unread,
Feb 1, 2013, 6:09:18 AM2/1/13
to qtcon...@googlegroups.com
Hi to everyone.

I'm using QTreeWidget with more then one column and I want set column width.
As first solution I have used setColumnWidth(), but without solution; then....

I read Qt docs ( take a look here http://qt-project.org/doc/qt-4.8/qheaderview.html#ResizeMode-enum ) and I try this solution:

         oQtHorizontalHeader:setResizeMode( nCol-1, QHeaderView_Fixed )
         oQtHorizontalHeader:resizeSection ( nCol-1, 150 )

where oQtHorizontalHeader is QTreeWidget:header().

But this doesn't works: aaaarghhh!

In disagree with Qt docs I have used

         oQtHorizontalHeader:setResizeMode( nCol-1, QHeaderView_Custom )
         oQtHorizontalHeader:resizeSection ( nCol-1, 150 )


and I have settle QHeaderView_Custom to 4; and it works fine!!!??? Can be introduced this defined value? Or is there something problem somewhere?

I'm using Qt 4.8.4 lib, last qtcontribs and last harbour.

Cheers

Luigi Ferraris

Luigi Ferraris

unread,
Feb 1, 2013, 6:26:33 AM2/1/13
to qtcon...@googlegroups.com
Hi to everyone.
I have done another test using
         oQtHorizontalHeader:setResizeMode( nCol-1, QHeaderView_Interactive )

         oQtHorizontalHeader:resizeSection ( nCol-1, 150 )
But it doesn't works too....

About my previous message: is not the solution; using QHeaderView_Custom it set default section size (I think 100) :-(

Luigi Ferraris

Pritpal Bedi

unread,
Feb 1, 2013, 2:15:37 PM2/1/13
to qtcon...@googlegroups.com
Hi


I have done another test using
         oQtHorizontalHeader:setResizeMode( nCol-1, QHeaderView_Interactive )
         oQtHorizontalHeader:resizeSection ( nCol-1, 150 )
But it doesn't works too....



   WITH OBJECT oTree:Header()
      :resizeSection( 0, 150 )
      :resizeSection( 1, 250 )
      :resizeSection( 2, 150 )
   ENDWITH
 

Pritpal Bedi

Luigi Ferraris

unread,
Feb 3, 2013, 6:06:06 AM2/3/13
to qtcon...@googlegroups.com
Hi Pritpal, many thanks for your answer. Your code is (more or less) like mine. I think problem is related with the moment: at creation time works fine after perhaps not, but I'm not sure I must do more test.

Anyway, many thanks

Luigi Ferraris

Reply all
Reply to author
Forward
0 new messages