[Qt-interest] QLayout Disaster (resizing)
Paul England
pengland at cmt-asia.com
Tue Jul 14 03:19:17 CEST 2009
Hi
Thanks for the response.
I'm mainly using the layouts to keep the widgets grouped. I can't think
of an easier (not to mention more elegant) way coding wise to do it,
considering each my_view_t has several widgets (a few QTableWidgets, a
few QPushButtons, QLineEdits, and so on). I'm not adverse to throwing
them out entirely, but I don't want to have to keep up with the
coordinates of each object... I'd have to calculate again where each one
goes for example when the font size is changed.
>>fixed size layouts don't make a lot of sense
Interesting. I'm curious as to why there's a SetFixedSize property in
the QLayout namespace. Although it's behavior definitely agrees with
your philosophy.
Paul
> On 14.07.09 09:13:03, Paul England wrote:
>
>> This is driving me nuts, so before I tinker any more I should make sure
>> what I'm trying to achieve is even possible.
>>
>> My application is a QDialog, which has quite a few nested
>> QHBoxLayouts/QVBoxLayouts and other QWidgets (QPushButtons, QLineEdits,
>> and QTableWidgetItems for the most part).
>>
>> I set all of my Layouts to sizeConstraint to QLayout::SetFixedSize, and
>> I put in an stretch of -1. The stretch works perfectly. If the GUI is
>> resized to anything larger than the necessary space, everything stays
>> positioned (in the top left-hand corner). However, when the GUI is
>> resized to something smaller, the view_layout is definitely resized.
>> Each my_view_t within it keeps it's relative position (all of the
>> widgets within it keep their relative spacing and sizng) but they will
>> overlap with each other. So, if I have a QTableWidget within each
>> my_view_t, if I resize the GUI small enough, I have 3 QTableWidgets
>> overlapping one another. This is obviously bad, and I can't figure out
>> exactly where I'm messing it up. The desired effect would be that the
>> GUI simply resizes, but all the widgets inside are of a static size. If
>> the user only wants to "see" one of the my_view_t's, he just resizes the
>> window to the desired size.
>>
>
> You're misusing layouts, fixed size layouts don't make a lot of sense, you
> could just as well leave away the layouts and position your widgets with
> absolute coordinates. This will also "fix" your current problems, widgets
> that are outside of the smaller size will just be clipped.
>
> Andreas
>
>
More information about the Qt-interest-old
mailing list