Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:18:52+00:00 2026-06-05T07:18:52+00:00

I have a GUI with two radio buttons inside a QButtonGroup container, which itself

  • 0

I have a GUI with two radio buttons inside a QButtonGroup container, which itself is inside a QGroupBox (this button group needs a right click context menu, and since a QButtonGroup doesn’t have a visual representation it doesn’t seem to have a setContextMenuPolicy method.) The following code snippet is supposed to update the state of the mutually-exclusive buttons in response to incoming data from a serial link:

elif widgetName in self.buttonBoxDict:
            buttonGroup = getattr(self.ui, self.buttonBoxDict[widgetName])
            checkedButton = buttonGroup.checkedButton()
            checkedButtonName = str(checkedButton.objectName())
            if value >= self.onValue and self.buttonDict[checkedButtonName][1] == self.offValue:
                checkedButton.toggle()
                assert(not checkedButton.isChecked())
                self.windowHandler.buttonChanged(self, self.onValue, cc)
            elif value < self.onValue and self.buttonDict[checkedButtonName][1] == self.onValue:
                checkedButton.toggle()
                self.windowHandler.buttonChanged(self, self.offValue, cc)

Unfortunately this isn’t working, I know initially the button selected here is checked, but the state of the button in the GUI never changes, and the assertion always fails even though the code seems to be executing properly. Any ideas as to why this might be going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:18:53+00:00Added an answer on June 5, 2026 at 7:18 am

    The problem you have is based on the fact that you are using a QButtonGroup that is set to be exclusive. If you take a look at the documentation you will see that it states the following:

    the user cannot uncheck the currently checked button by clicking on it; instead, another button in the group must be clicked

    I don’t know the logic of you application but if you are using an exclusive button group you will need to set a diff button to be checked or do not use an exclusive group and enforce the checks yourself.

    The following is a small example of what you are seeing:

    import sys
    from PyQt4 import QtGui
    
    app = QtGui.QApplication(sys.argv)
    button1 = QtGui.QCheckBox('test 1')
    group = QtGui.QButtonGroup()
    group.setExclusive(True)
    group.addButton(button1)
    print button1.isChecked()
    button1.toggle()
    print button1.isChecked()
    button1.toggle()
    print button1.isChecked()
    # toggle seems not to work, add a second button
    button2 =  QtGui.QCheckBox('test 2')
    group.addButton(button2)
    print button2.isChecked()
    button2.toggle()
    print button1.isChecked()
    print button2.isChecked()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this GUI screen shots from the design team which i needs to
Here is the scenario : I have a gui which contains two buttons.Now is
I have a GUI program, which would call a cmd in this GUI program.
I have a GUI program with one Exit button. When clicking this button, it
I have two .java's one called GUI.java, another called CustomPanel.java Once a button is
Suppose I have a design like this: Object GUI has two objects: object aManager
I have a GUI application in Python that has two buttons both aligned to
I have two programs: one CLI program, and one GUI. The GUI is a
Say I have two classes, and neither of them are GUI components. Class A
I have a GUI app written in C++/CLI which has a load of configurable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.