[Qt-interest] Autosize QTableView

Israel Brewster israel at frontierflying.com
Mon Jan 19 23:34:29 CET 2009


tableView->horizontalHeader()->offset() returns zero for me. However,  
what is working is horizontalHeader->length()+verticalHeader->width().  
When I set the window size to that plus the margins from the layout, I  
get the proper width. I think before I was trying horisontalHeader- 
width() rather than length(), which didn't work. Still seems a bit  
kludgy (at least, as compared to a QTableView::optimumSize() function  
or the like), but it is relatively clean, and I get the proper width  
without having to hardcode fudge values. Thanks!
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------


On Jan 19, 2009, at 8:55 AM, Alexandre Beraud wrote:

> Indeed, I think that you just have to add the QHeaderView::offset() to
> the QHeaderView::length(). Let me know if it works.
>
> Regards,
>
> Alex
>
>
> Israel Brewster a écrit :
>> On Jan 19, 2009, at 8:25 AM, Alexandre Beraud wrote:
>>
>>> Hi,
>>>
>>> I have not tested it, but my first guess would be to use
>>> QHeaderView::length() for both directions.
>>>
>>> Regards,
>>>
>>> Alex
>>
>> Oh, yeah, I tried that one too- came up short. Of course, maybe I  
>> just
>> needed to add the width of the vertical header to the width of the
>> horizontal header (and visa-versa for vertical) - I just tried the
>> width of the horizontal header by itself. I'll have to try that.  
>> Thanks.
>>
>> -----------------------------------------------
>> Israel Brewster
>> Computer Support Technician
>> Frontier Flying Service Inc.
>> 5245 Airport Industrial Rd
>> Fairbanks, AK 99709
>> (907) 450-7250 x293
>> -----------------------------------------------
>>
>>>
>>>
>>>
>>> Israel Brewster a écrit :
>>>> I'm trying to figure out how to automatically size a QTableView  
>>>> (and
>>>> enclosing window) to fit the contents of the table view without  
>>>> scroll
>>>> bars, if possible. Of course, this would be limited by the size  
>>>> of the
>>>> display, among other things. I thought I might be able to just  
>>>> use the
>>>> size hint from the QTableView, but this is way smaller than  
>>>> needed. I
>>>> also tried adding the column widths and the width of the vertical
>>>> header (and the same basic procedure for the height), but this also
>>>> came out too small, by almost a column. I can, of course, add some
>>>> arbitrary fixed number to this amount to make up the difference
>>>> (actually, this is what I am doing), but that just feels kludgy  
>>>> to me.
>>>> The height is even more complicated, as I need to take into account
>>>> things like the tool bar, title bar, status bar, etc. Is there a
>>>> better way to determine the needed size? Thanks.
>>>>
>>>> -----------------------------------------------
>>>> Israel Brewster
>>>> Computer Support Technician
>>>> Frontier Flying Service Inc.
>>>> 5245 Airport Industrial Rd
>>>> Fairbanks, AK 99709
>>>> (907) 450-7250 x293
>>>> -----------------------------------------------
>>>>
>>>>
>>>> _______________________________________________
>>>> Qt-interest mailing list
>>>> Qt-interest at trolltech.com
>>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>>
>>>>
>>>>
>>>
>>>
>>> -- 
>>> BERAUD Alexandre
>>> Ingénieur Développement
>>>
>>> Infflux - Informatique & Flux
>>> Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
>>> Mail: aberaud at infflux.com
>>> Visitez notre site :  www.infflux.com
>>>
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>>
>
>
> -- 
> BERAUD Alexandre
> Ingénieur Développement
>
> Infflux - Informatique & Flux
> Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
> Mail: aberaud at infflux.com
> Visitez notre site :  www.infflux.com
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list