I am trying to line up widgets from two different QGridLayouts. The idea is the following: I have many rows of widgets in the QGridLayout of a scroll frame. Each row contains maybe 8 columns of other widgets (so a grid of 8xN widgets, N = # of rows). The first widget in that row is a show/hide button that when checked, will show another widget with the same layout just below that row (i.e. that shown widget has rows of widgets, each row has 7 columns of widgets). So the shown widget will be inserted initially and be shown/hidden when the show button is toggled.
The image below illustrates my setup. The widgets indicated by the red bracket labelled "A" are the ones I show when checking the check box on the left (they do not have their own show button).
The problem I need to solve is how to get the shown widgets to line up with all of the others. I thought of two options here:
- Put all widgets in the same layout and just loop through the widgets that I need to show/hide to do so. The benefit to this is all the widgets are lined up since they are in the same layout. The bad thing is if I have hundreds of rows of widgets (which is common), it takes a very VERY long time to show them all.
- Put the subwidgets in their own container widget and have the show/hide button simply show/hide THAT widget. The benefit is that this is much MUCH faster than showing/hiding each individual widget, but the bad side is the widgets are now not lined up because the subwidgets are in a different layout. I'm thinking this is the better path to take. I just need to figure out how to align all the like widgets.
Hopefully that was clear. I am using Qt 5.11. Thanks ahead of time for the assistance.