[PyQt] question about size hints

Yao Ko koyao at raptr.com
Mon May 3 18:26:18 BST 2010


On Sun, May 2, 2010 at 5:05 AM, Darren Dale <dsdale24 at gmail.com> wrote:
> On Sun, May 2, 2010 at 1:51 AM, Yao Ko <koyao at raptr.com> wrote:
>> On Sat, May 1, 2010 at 5:47 AM, Darren Dale <dsdale24 at gmail.com> wrote:
>>> Please excuse me for bumping. Does anyone have a suggestion?
>>>
>>> On Sun, Apr 18, 2010 at 12:42 PM, Darren Dale <dsdale24 at gmail.com> wrote:
>>>> I have a question about size hints that can be illustrated with the
>>>> simple example below. If I create my Test widget so it returns a size
>>>> hint of (200,100), it is rendered with a size of 200, 100. If I create
>>>> Test so it is 100x70, it is rendered to be 200x100. If I create test
>>>> to be 1000x700, it is rendered to be 853x533 (my screen resolution is
>>>> 1280x800). If I set the size policy to be fixed, then the central
>>>> widget size policy is respected, but I can't resize the window. How
>>>> can I make m respect the size hint of the central widget, but still
>>>> maintain the ability to resize the window?

Looks like the problem is not with the Test widget, but with the
initial size of MainWindow.  What if you set the initial size of
MainWindow to whatever is defined in Test.sizeHint() in
MainWindow.__init__() ?  This way, the MainWindow will start at the
size needed to hold the Test widget at full size, but it will still
allow the Test widget to be smaller if user so desires.

Yao


More information about the PyQt mailing list