[Qt-interest] Aspect Ratio with QWidget::heightForWidth(int)
Huseyin Kozan
huseyinkozan at gmail.com
Wed Jul 22 12:48:56 CEST 2009
On Wed, Jul 22, 2009 at 13:37, David Boddie <david.boddie at nokia.com> wrote:
> Huseyin Kozan wrote:
>
> > I tried to make a widget (and frame) which have a fixed ratio (I mean
> like
> > square) .
>
> [...]
>
> > There is a quarterly document here:
> > http://doc.trolltech.com/qq/qq04-height-for-width.html
> > But I couldnt work it.
> >
> > What is the correct way to do this ?
>
> Have you tried implementing sizeHint() in the way shown in the article?
> Does that work?
>
> David
Is this sizeHint() thing for initial size ?
I tried it like this:
//..
virtual int heightForWidth(int w) const;
virtual QSize sizeHint() const;
}
QSize FixedRatioWidget::sizeHint() const
{
int w = width();
return QSize( w, heightForWidth(w) );
}
But I cannot see the difference. What is the requirements for layouting
parents and childs ? I mean we cannot force the main window to maintain the
ratio, and do I need to add spacers near the promoted widget, and/or child
widgets ?
Hüseyin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090722/e363f2ec/attachment.html
More information about the Qt-interest-old
mailing list