I have a need for windows that maintain a set aspect ratio, so I implemented 
heightForWidth(). Since I'm still exploring, I made it very simple (this 
function is called by a wrapper class that actually implements 
heightForWidth()):

 int grafRec::doHeightForWidth(int w)
{
        return w/2;
}

I set a size policy:

                QSizePolicy policy(QSizePolicy::Preferred, 
QSizePolicy::Preferred);
                policy.setHeightForWidth(true);
                content->setSizePolicy(policy);

The object called "content" is a subclass of QWidget and it is embedded in a 
cell of a QGridLayout. There are no other cells in the layout occupied. The 
layout and managed content widget are embedded in a top-level widget.

This actually works up to a point. As I make the window get wider, it also gets 
taller in proportion. But evidently Qt is enforcing a height that is *at least* 
half the width, where I really need a height that is *exactly* half the width.

Is this working as expected, that the height returned by heightForWidth() is 
really a minimum height? If that is so, is there a way to achieve what I really 
want?

Thank you all!

-John Weeks

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to