PDA

View Full Version : Half-resizable window



evergreen
16th May 2011, 09:31
Hello everyone,

I'm working on a main window. I want the user to be allowed to resize it vertically, but not horizontally.
The fisrt idea I got was to put :
resize(630, 380);
setFixedWidth (630);
in the constructor but it automatically disable the resize buton of the title bar (between close and reduce)
Is it possible to impose an horizontal size but let this auto-resize option available verticaly?

Zlatomir
16th May 2011, 09:45
You can set both the minimum and maximum width to the same value.

LE: i have tried setFixedWidth and it works as expected with SDK 1.1 on Windows 7.

evergreen
16th May 2011, 10:02
I've tried it : setMaximumWidth(630); setMinimumWidth(630);

The window gets the size I want but the recize button of the tittle bar is still disabled.
To be clearer I want that when the user click on this button, the window's width stays at 630px but the heigth be miximized.

Zlatomir
16th May 2011, 10:12
My bad - i didn't understood what you meant by "auto-resize" and "resize button" - but i don't think that is possible to keep that button usable with one fixed size, that maximize button is for maximizing the window on both directions, not on only on one.

But your users can manually drag the margin of the window to "maximize" it on only one direction, isn't it acceptable?

evergreen
16th May 2011, 11:39
Sorry my bad about the vocabulary.
The user definitively can drag the vertical margin only ; but I really think it would be more powerfull if you let him mawimize it in one click.
I'm just begining with Qt, i'm not sure of what's possible and what's not.
If anymore idea, it's welcome.

Added after 1 19 minutes:

I found a solution for the one who finf the same proble :

resize(630, 380);
setFixedWidth(630);
setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint));

The flags enable the Maximize button, and respect the limited width.

nish
16th May 2011, 11:52
I found a solution for the one who finf the same proble :

resize(630, 380);
setFixedWidth(630);
setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint));

The flags enable the Maximize button, and respect the limited width.
be sure to check it on other OS and systems, window flags are known to work differently on different systems.

dholliday
16th May 2011, 12:37
Also I've some experiance with this.

You should also do this on the init of the form.

int maxSize = this->sizeHint().height();
this->setMinimumHeight(maxSize);
this->setMaximumHeight(maxSize);

This is because the Idea min height is different depending on the OS's.
This ensures that you get the appropriate minimum height befor the end user sees the form.

gambr
15th September 2011, 14:06
Thanks dholliday,
that's what I was looking for, even if a simpler call in Qt API would be nice.

Regards
Gianni