You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using the following function to check the state when a QPushButton is clicked:
neko=""defbuttonCat(button: QPushButton, group: QButtonGroup):
globalnekoprint(f"You clicked button {button.text()}")
ifneko==button.text():
print("The button was clicked again.")
group.setExclusive(False)
forbuttoningroup.buttons():
button.setChecked(False)
group.setExclusive(True)
neko=''else:
print("The button was clicked for the first time.")
neko=button.text()
The main functionality of this function is to deselect the button when it is clicked again. Meanwhile, I'm using the following method to invoke the above function:
# Create a QButtonGroup to manage mutually exclusive buttons.button_group=QButtonGroup(self)
# Create H1 and H2 buttons.h1_button=QPushButton("H1")
h1_button.setCheckable(True)
h2_button=QPushButton("H2")
h2_button.setCheckable(True)
# Add the buttons to the button group.button_group.addButton(h1_button)
button_group.addButton(h2_button)
button_group.setExclusive(True) # Set them to mutual exclusive mode, meaning only one button can be selected at a time.button_group.buttonClicked.connect(lambdabutton: buttonCat(button, button_group))
The behavior is normal when not using QSS.
The text was updated successfully, but these errors were encountered:
I tried using the following function to check the state when a
QPushButton
is clicked:The main functionality of this function is to deselect the button when it is clicked again. Meanwhile, I'm using the following method to invoke the above function:
The behavior is normal when not using QSS.
The text was updated successfully, but these errors were encountered: