Half-resizable window

  • 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?

  • Need some more info to understand what you are trying to do...
    By 'resize' / 'auto-resize', do you really mean 'maximize'?
    Or which platform / window system are you on?

  • How about you set the minimum and maximum sizes for the widget, where for the width the minimum equals the maximum but for the height you give different values?

  • ludde : Sorry, I really meant maximized. I'm on windows XP.

    Andre : I tried to give the same minimum and maximum to width only but it also disable the maximize button.

  • But it makes perfect sense that that disables the maximize button. If you limit the size to a specific width, you can not resize it to fill the screen (what the maximize button does). It would be confusing to the user if you have a maximize button, that does not actually maximize the window.

  • I see what you mean but I've already seen lots of apps that allow you to miximize only one dimension.
    Maybe the maximize action could be redifined.
    Maybe I'm a dreamer, I just begin with Qt!

  • Seems like someone dictates that a window with a maximum widht or height should have a disabled maximize button. Not sure if it's Qt or Windows, though. If it's Qt you might be able to get around it, if it's Windows, it might be more difficult (at least using Qt code - you might find something in the Windows APIs).

    The fact that doing
    @w.setWindowFlags(w.windowFlags() | Qt::WindowMaximizeButtonHint);@
    on a window does not bring the maximize button back to enabled probably means that it is Windows, not Qt, that dictates this.

  • Bad news tho...

  • I found a simple solution for the one who find the same problem :

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

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

    Thanks for helps

  • Right... the documentation actually says you have to use Qt::CustomizeWindowHint to make Qt::WindowMaximizeButtonHint have any effect, so that was not so unexpected. If I would just have read the manual I would have probably have seen that too... :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.