radio_button = QRadioButton("Option 1") radio_button.setObjectName("option1")
button_group = QButtonGroup() radio1 = QRadioButton("Option 1") radio2 = QRadioButton("Option 2") button_group.addButton(radio1) button_group.addButton(radio2) # Get the selected radio button selected_radio = button_group.checkedButton()
radio_button = QRadioButton("Option 1") radio_button.setStyleSheet("background-color: grey; color: white;")In this example, we create a QRadioButton widget with the label "Option 1". We change the background color to grey and the text color to white using the setStyleSheet() method. This can be used to customize the appearance of the widget.