0
votes

I have a grid layout shown below containing 3 QLabel objects that are used to display 3 seperate video streams. Some streams can be toggled off and I want the display to automatically resize within the layout to the maximum size.

layout When using two adjacent QLabels (red & blue alone) I was able to do this by using setVisible(false) on one label, and the other label would resize to fill the layout area. But adding a third label object underneath in the following layout has broken this although i'm not sure why.

Here is 2 'streams' activated just using two adjacent qlabels in a gridlayout (Just testing with webcam, 2nd display has no video yet)

twostream and then after calling label2->setVisible(false)

1stream This is the result I want when using 3 labels. When I try this and set label 2 and 3's visibility off, this is what I get:

bad1stream The gridlayout containing the qlabels is using a setFixedSize constraint, and each qlabel is using a preferred sizing policy for horizontal and vertical. You can see that the vertical resizing works as it should but not the horizontal. How can I adjust the label to correctly resize horizontally?

the full style sheet for the ui can be seen here: http://pastebin.com/vJUkMGT8

1

1 Answers

1
votes

It will not work with the QGridLayout because it it supposed to be more like a table. Same number of rows and columns. If you are going to have those three streams you can use QHorizontalLayout for the top two objects and put it with the third object into a QVerticalLayout.

The problem is when you close second stream (hide it). Actually you should hide third QLabel and play third stream in the second QLabel.

It is quite special layout which you should maybe inherit and write your own, especially when you are going to have more streams than three.