Results 1 to 3 of 3

Thread: Struggling with layouts in QtCreator

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Struggling with layouts in QtCreator

    I've been using QtCreator for some time, but I have to admit, I really don't understand all the parameters that can be used in a layout.

    For example, I have a vertical layout with three QFrames.

    The Qframes have vertical stretch and horizontal stretch policies. But the layout also has a layoutStretch property, which is a list (I think) of the vertical stretch properties for each widget it contains.

    Are these the same thing? Which one takes precedent (they aren't kept in sync).

    Also, it seems sometimes widgets inside a layout overlap each other. I didn't think that was supposed to happen. Or, maybe it's a widget contained by the QFrame that goes outside its frame Either way, stuff definitely overlaps. What are the rules for this?

    Thanks!

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,243
    Thanks
    303
    Thanked 866 Times in 853 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Struggling with layouts in QtCreator

    AFAIK, the layout's policies take precedence over the widgets inside it. The layout will try to honor the widgets' minimum size and size hints and size policy, but i suppose if you externally compress a layout by forcing it into a container smaller than the minimum sizes of the widgets in the layout, then the layout might have no choice except to overlap widgets.

    On the other hand, if it is a custom widget doing its own drawing and that drawing doesn't respect the bounding rect imposed on it by the layout, it will color outside the lines and appear to be overlapping.

    Stretch in layouts is a mystery. I have not found anywhere in the documentation that describes how stretch actually behaves other than cryptic things like
    Sets the stretch factor at position index. to stretch.
    Well, duh, but what does that mean? The closest I have come to understanding it is that if you have two panes in a layout, one with stretch factor 1 and the other with stretch factor 2, the second seems to stretch at twice the rate of the first. Sometimes. Until you add a third or fourth pane.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    davethomaspilot (4th February 2023)

  4. #3
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Struggling with layouts in QtCreator

    I'd love to see something that discusses each layout parameter, both in QtCreator and from code (e.g, setting sizeHint in QtCreator is done using several other parameters (I think)).

    Some have recommended purchasing a book that supposed to have a good explanation--I'd have to track down the name again. But, it was qt4 and I don't know how much has changed since then.

    I always get something working, close to what I want, but it's very empirical. Tweak, try again until I get something like I want.

Similar Threads

  1. struggling with QT JAVA
    By sanjeet in forum Qt Programming
    Replies: 2
    Last Post: 25th April 2013, 12:03
  2. Struggling qith Qt/Phonon
    By burlyjez in forum Qt Programming
    Replies: 0
    Last Post: 27th November 2010, 14:02
  3. Struggling with interface classes
    By JPNaude in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2010, 10:24
  4. Struggling with QThread...
    By TemporalBeing in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2009, 21:46
  5. Struggling with value space
    By UnicycleBloke in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 29th May 2008, 00:26

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.