Results 1 to 4 of 4

Thread: Resize button when using layout

  1. #1
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Resize button when using layout

    I have listWidget on my form and I had problem with it, becouse when user was resizing window so it couldn't hold all listWidget's items - scrollbar wasn't appearing.
    I solved it by marking "Lay out vertically" option, but now i can't resize button which is on the same form.

    So is there way to change size of button when Vertical Layout is specified?
    Or is it possible to force scrollbar to appear when form is too small?

    Thanks in advance and sorry for bad english.
    Last edited by Macok; 25th January 2009 at 18:53.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Resize button when using layout

    Why would you want to manually resize the button?

    You should apply a layout (as you did by clicking on "Lay out vertically"). If it doesn't satisfy you, you can manipulate its contents by using spacers and size policies of widgets (or apply a different layout - like the grid layout). At a last resort you can set the exact size of each widget by setting its minimum and maximum size but this has many disadvantages and is almost never needed.

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

    Macok (25th January 2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Resize button when using layout

    Quote Originally Posted by wysota View Post
    Why would you want to manually resize the button?
    I'm new to Qt, and I'm only learning it now.

    I see that it's almost impossible to change button size when using layouts.
    So I'll put another question:
    When you are creating your gui in Qt Designer, are you always using layouts?
    Should I use it or not?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Resize button when using layout

    Quote Originally Posted by Macok View Post
    I'm new to Qt, and I'm only learning it now.

    I see that it's almost impossible to change button size when using layouts.
    Again, why would you want to do that? The button knows how big it should be. If you want to force your own size, you can do it in many ways - more or less gracefully. If you want to resize the button, the easiest way is to put it in a layout where its cell size is what you want your button to be. The cell size is determined based on all widgets occupying a particular column or row of the layout. If that's not enough for you, you can use spacers. If that's not enough - use size policies. If again this is not enough, use layout constraints and/or set minimum/maximum size of the widget manually. But never try to move the widget with a mouse after placing it in a layout (unless you want to drag it to another cell size) - it doesn't make any sense as the widget wouldn't know what to "dock" itself to and how to control its size.

    When you are creating your gui in Qt Designer, are you always using layouts?
    Should I use it or not?
    Yes, always. Treat it as a rule and don't try to avoid it unless you have a very wacky usecase and you are sure you shouldn't use a layout in this particular situation. Your current situation is certainly not one of those.

  6. The following user says thank you to wysota for this useful post:

    Macok (30th January 2009)

Similar Threads

  1. Move and resize with layout
    By waediowa in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2008, 08:16
  2. How to resize a Button
    By Walsi in forum Newbie
    Replies: 3
    Last Post: 2nd April 2008, 01:08
  3. QGLWidget problem
    By MarkoSan in forum Qt Programming
    Replies: 33
    Last Post: 8th December 2007, 15:50
  4. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 17:11
  5. problem with Tool button n Layout
    By arjunasd in forum Qt Tools
    Replies: 11
    Last Post: 24th July 2007, 21: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.