Results 1 to 8 of 8

Thread: Half-resizable window

  1. #1
    Join Date
    May 2011
    Posts
    18
    Thanks
    2

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

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Half-resizable window

    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.

  3. The following user says thank you to Zlatomir for this useful post:

    evergreen (16th May 2011)

  4. #3
    Join Date
    May 2011
    Posts
    18
    Thanks
    2

    Default Re: Half-resizable window

    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.

  5. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Half-resizable window

    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?

  6. #5
    Join Date
    May 2011
    Posts
    18
    Thanks
    2

    Default Re: Half-resizable window

    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.
    Last edited by evergreen; 16th May 2011 at 10:39.

  7. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Half-resizable window

    Quote Originally Posted by evergreen View Post

    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.

  8. #7
    Join Date
    Jan 2010
    Posts
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Half-resizable window

    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.

  9. The following user says thank you to dholliday for this useful post:

    gambr (15th September 2011)

  10. #8
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Half-resizable window

    Thanks dholliday,
    that's what I was looking for, even if a simpler call in Qt API would be nice.

    Regards
    Gianni

Similar Threads

  1. Qt Widgets seen half transparent when using stylesheets
    By codeslicer in forum Qt Programming
    Replies: 5
    Last Post: 14th December 2010, 09:52
  2. Window Style: No border but resizable
    By Peppy in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2010, 18:21
  3. Why QGraphicsItem moveing is valid in half?
    By litterflybug in forum Qt Programming
    Replies: 2
    Last Post: 13th December 2009, 13:14
  4. color one half of the button?
    By tommy in forum Qt Programming
    Replies: 4
    Last Post: 26th December 2007, 19:42
  5. making an application window non resizable
    By aegis in forum Qt Programming
    Replies: 16
    Last Post: 13th May 2007, 19:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.