Results 1 to 4 of 4

Thread: How to delay the layout-ing of a QGridLayout, until all widgets are visible?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,315
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to delay the layout-ing of a QGridLayout, until all widgets are visible?

    Laying out the grid is part of the geometry calculations that take place prior to anything being shown, so it isn't possible to show the widgets -before- their sizes and positions have been calculated by the layout and its container. Blocking the setGeometry() calls in the way you do is undoubtedly preventing that process from working correctly, which is why you have widgets appearing in odd places.

    Each time you change the visibility status of a widget, the layout -must- be recalculated in response, so there is no way to avoid that either. Changing the visibility probably results in a resizeEvent() as well as an eventual paintEvent() if the widget is made visible. Layouts are likely monitoring resizeEvent() for the widgets they manage, which in turn triggers a geometry recalculation.

    You could try calling blockSignals() but I do not know how much of the layout calculation is the result of signals or the result of events.
    <=== 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.

  2. #2
    Join Date
    Jan 2020
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to delay the layout-ing of a QGridLayout, until all widgets are visible?

    Is there then a way, to make the layouting/size calculation easier for the widgets and the layout? For example, all rows will have the same height, but I'm unsure on how to communicate that to the grid layout.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,315
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to delay the layout-ing of a QGridLayout, until all widgets are visible?

    I'm unsure on how to communicate that to the grid layout.
    I think the layout management uses the sizeHint() among other parameters in calculating geometry. You may get some help from this documentation and these examples. In particular, the Flow Layout example shows how to implement a custom layout manager, which might give you some insights into how and when the geometry calculations are performed.

    You might find that implementing your own layout is the best way to optimize performance for your specific case.
    <=== 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.

Similar Threads

  1. Force all widgets in a QGridLayout to be visible
    By SeanM in forum Qt Programming
    Replies: 2
    Last Post: 29th January 2014, 22:07
  2. Repositioning widgets in QGridLayout
    By Rayven in forum Qt Programming
    Replies: 8
    Last Post: 21st March 2011, 14:30
  3. Replies: 2
    Last Post: 16th December 2010, 11:52
  4. space between widgets in qgridlayout
    By demol in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2010, 20:07
  5. Delay in loading qt widgets
    By pinakis in forum Qt Programming
    Replies: 1
    Last Post: 3rd June 2009, 06:56

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.