Search code examples
qtqt-designerqwidget

Different options depending on QRadioButton


I have a Qt Designer form (widget), that includes N radio buttons. And i want to see different options (QGroupBox, etc) depending on selected button in the same widget. What is the right way to solve this problem?

Of course, i can place all boxes in widget and change their visibility depending on selected radio button, but that is not perfect i'm sure.


Solution

  • It seems like QStackedWidget is what you're looking for.

    Put your radio buttons into a QButtonGroup, then connect QButtonGroup::buttonClicked(int) to QStackedWidget::setCurrentIndex(int).