Results 1 to 4 of 4

Thread: Automatic resizing of child widgets

  1. #1
    Join Date
    Mar 2010
    Posts
    55
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Automatic resizing of child widgets

    Hi all,

    First time poster here. Decided to give Qt a shot, after getting fed up with wxWidgets' absolutely horrid GUI designer and clunky macros.

    I've installed Qt 4.6.2 and Qt Creator on my Windows box, and I've been experimenting with the GUI editor. It's fantastic! But I've run into a situation.
    I've got my QMainWindow and I need a treeview and an MDI client widget. So first thing I tried to do was add a QHBoxLayout, and successfully added a QTreeView and QMdiArea into it (this is all in the WYSIWYG editor.)

    That's fine, but I'd like the QHBoxLayout to completely fill up the client area of the window, and resize automatically as the parent window gets resized. I looked through the properties and tried a few, but couldn't find anything relevant. Is there a way to do this automatically, or do I have to intercept the parent window's resize event, and manually resize my layout box?

    I then tried adding a QDockWidget and putting the QTreeView into it. But again the QTreeView doesn't fill its parent. Can I do this automatically, or is this the same story as before?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Automatic resizing of child widgets

    Does your main window has a layout ? What did you add the QHBoxLayout to ?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Automatic resizing of child widgets

    In Designer select the main window and look for the layout tools on the toolbar. You should be able to dispense with your explicitly added QHBoxLayout and rely on the layout Designer attaches to the main window client area.

  4. The following user says thank you to ChrisW67 for this useful post:

    JovianGhost (11th March 2010)

  5. #4
    Join Date
    Mar 2010
    Posts
    55
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Automatic resizing of child widgets

    Quote Originally Posted by aamer4yu View Post
    Does your main window has a layout ? What did you add the QHBoxLayout to ?
    I added the QHBoxLayout directly to the window, as the central widget.

    Quote Originally Posted by ChrisW67 View Post
    In Designer select the main window and look for the layout tools on the toolbar. You should be able to dispense with your explicitly added QHBoxLayout and rely on the layout Designer attaches to the main window client area.
    I see that toolbar, but every one of the layout buttons are greyed out!
    If I right-click the window and choose "Lay out", the only item that's available is "Adjust size".

    [edit]
    Ok nevermind, I figured out what I was doing wrong-- first I have to add the widgets THEN choose the layout. Dammit I'm an idiot.

    Thanks guys!
    Last edited by JovianGhost; 11th March 2010 at 13:10.

Similar Threads

  1. Automatic image resizing too slow
    By mhbeyle in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2009, 07:55
  2. Resizing child widget on changing size of parent?
    By anupamgee in forum Qt Programming
    Replies: 3
    Last Post: 13th November 2009, 08:39
  3. Resizing child Widget
    By Pragya in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2007, 06:58
  4. Replies: 14
    Last Post: 19th March 2007, 08:48
  5. Automatic Resizing
    By ToddAtWSU in forum Qt Programming
    Replies: 7
    Last Post: 22nd January 2007, 18:41

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.