Reputation: 135
I have a ui I am working on, and I am trying to get the available buttons to change when I press one of the current buttons. For example, if buttons 1-9 are shown, if I press button 2, I want buttons 10-13 to show and buttons 1-9 to disappear. I am using qtdesigner, but I can hardcode this if needbe, I just dont know how to get this without opening and closing the entire window
Here are my buttons:
Thanks!
Upvotes: 0
Views: 1456
Reputation: 1640
The easiest way to do that is,
Obs: Remember that when hiding the buttons all of the other will adjust itself according to the layout's policies.
Another way to do that would be really adding and removing the buttons you need:
layout.addWidget(btn)
layout.removeWidget(btn)
btn.hide()
btn.close()
del btn
Obs: you will have to struggle a bit more adding and removing the buttons from your layout but that's how it is.
There is also the option of instead of putting all the buttons in layouts you divide it in groups and put it in another widget(making it as layers) so when you have to remove certain amount of buttons you just remove that widget and all from that will be gone with it. Also you can have a look in ButtonGroup and see if it'd serve you for something.
Upvotes: 1