[Qt-interest] QLayout Disaster (resizing)

Andreas Pakulat apaku at gmx.de
Tue Jul 14 02:26:22 CEST 2009


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

-- 
You will be the victim of a bizarre joke.



More information about the Qt-interest-old mailing list