how to resize Widget in stackedLayout?
hi folks, I'm trying to make a overlapping widget, in which a label and a sub-classed widget showing on on another at the same time.
the problem is I want to change the background color of the label, then I found the size of the label is actually the whole qstackedlayout. I tried to resize the label to make it smaller and didn't work. tried to add another layout and found addlayout is actually not a member function of QStackedLayout.
what to do? thanks you guys in advance!
If you want to overlap two widgets you have to position the top widget yourself over the other one. A QStackedLayout allows you to have several widgets at the same place at the same time but only one will be visible at a time.
self over the other one. A QStackedLayout allows you to have several widgets at the same place at the same time but only one will
hi SGaist, I set QStackedLayout::StackAll. it allows all the widgets show at the same time.
but my problem is once I tried to change the background color of one widget, but I found the size of the label is the whole stackedlayout...
Right, I forgot about StackAll, thanks for the reminder.
But still, a layout will handle the size and position of the widget, since you want yours to float at a precise position, do the positioning yourself.
@SGaist yea...the problem is it seems I cannot change the size of the widget in stackedlayout...is it normal? the widget just covers automatically the whole stackedlayout.
Yes it is normal. A layout manager does that: it position and resize the widgets you put in so you don't have to do everything by hand. It will adapt as needed when you resize the widget on which you applied the layout.
@SGaist aha. that's why...
but is there a way to resize one of the widget in this case? I tried to add another layout(QHBoxLayout) into stackedlayout and it didn't work.
it seems it's impossible to resize it in a stackedlayout....in QHBoxlayout at least you can use addStrech function.
Where exactly would you like that widget to appear ?
@SGaist so I made a widget in which a picture is rotating. A label is much smaller and will overlap on the widget. They are combined in a qstackedlayout. So I want to change the background color of the label when the rotation of the bigger widget reaches some level.
but as I said the background of the label covers acutually the whole qstackedlayout. that's kinda annoying. I have placed the label in the middle with setAlignment. Only wish is to resize the label , which seems to be incredibly hard.
so the whole object should look like two concentric circles. I want to change the color of the inner circle without changing the color of the outer circle.
I hope I have explained it in a proper way.
Sounds like something for the Graphics View Framework
@SGaist thnx so much for the help man imma check it out.