[Qt-interest] QHeaderView height

Benjamin Sonnemann b.sonnemann at gmail.com
Fri Apr 3 09:08:30 CEST 2009


Well the default role is DisplayRole, so try this instead:

  QVariant header_height    = model()->headerData( 0,
Qt::Horizontal,Qt::SizeHintRole);
  int hh = header_height.toInt();
  printf( "model()->headerData( 0, Qt::Horizontal ) = %d\n", hh );

Didnt test it though :P

Benjamin Sonnemann


On Fri, Apr 3, 2009 at 1:43 AM, Paul England <pengland at cmt-asia.com> wrote:

> Thanks for the reply.
> Although this seems to be giving me a zero.
> class my_table  : public QTableWidget
> {
>
> };
>
> my_table::do_something()
> {
>   QVariant header_height    = model()->headerData( 0, Qt::Horizontal );
>   int hh = header_height.toInt();
>   printf( "model()->headerData( 0, Qt::Horizontal ) = %d\n", hh );
> }
>
> Output it "0".
> Paul
>
>  Well perhaps you could try it with:
>>
>>
>>      QAbstractItemMode::headerData ( int /section/, Qt::Orientation
>>      <http://doc.trolltech.com/4.1/qt.html#Orientation-enum>
>>      /orientation/, int /role/ = Qt::DisplayRole );
>>
>> just call this on the widgets model, with the proper orientation and
>> SizeRole.
>>
>> Benjamin Sonnemann
>>
>>
>> On Thu, Apr 2, 2009 at 6:49 PM, Paul England <pengland at cmt-asia.com<mailto:
>> pengland at cmt-asia.com>> wrote:
>>
>>    Hey Gang
>>
>>    I'm resizing a QTableWidget.  Since I don't know of a way to set the
>>    height of the widget to match the sum of the height of the rows + the
>>    height of the horizontalHeader(), I'm doing it manually.
>>
>>    Caveat: no idea on Earth how to get the height of hozirontalHeader().
>>    horizontalHeader()->sectionSize() gives me the width, which I can
>>    easily
>>    get from any one of the columns, so that's a bit useless.  Am I doing
>>    this the hard way?  Missing something?
>>
>>    Heading to bed, so won't be able to give a proper thank you email
>>    for a bit.
>>
>>    Cheers
>>    Paul
>>    _______________________________________________
>>    Qt-interest mailing list
>>    Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>>    http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090403/b7e0b81e/attachment.html 


More information about the Qt-interest-old mailing list