[Qt-interest] QTreeView or QTableView size
Malyushytsky, Alex
alex at wai.com
Fri Sep 16 03:45:15 CEST 2011
There is no "automatic" way to do what you want as far as I understand you.
But you always can create a function which might be ideal for your specific situation,
For example you can control widget size yourself ( through for example setMinimumSize, setMaximumSize ).
after you calculate the dimensions required that scrollbars are visible (the easiest way to calculate is - resizeSections as you were advised below).
I used such approach myself and want to warn you that it will not work well if you have dynamically changing contents or editable table
and you might need to play with parent layout to achieve good-looking result even with static data.
Regards,
Alex
-----Original Message-----
From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of jani at wbsources.com
Sent: Wednesday, September 14, 2011 3:24 PM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] QTreeView or QTableView size
That only resizes the content, but not the view itself...
I want to grow the table to the minimum size here no scrollbars are visible.
> You might try this:
> QTableView::horizontalHeader()->resizeSections(
> QHeaderView::ResizeToContents);
>
> On Thu, Sep 8, 2011 at 1:58 AM, <jani at wbsources.com> wrote:
>
>> Hello Gents,
>>
>> Is it possible to automatically resize QTableView to its content?
>> Now I set its size to QTableView::horizontalHeader()->height() +
>> counting the lines and calling rowHeight() on all of them.
>> QSizePolicy::Minimum does not seem to affect how my table is sized.
>> Also there is a default minimum size (256x192) for all QTableView
>> even if is set minimum size to to zero.
>>
>> Any help would be greatly appreciated.
>> Thanks.
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
>
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list