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 8135869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:33:37+00:00 2026-06-06T10:33:37+00:00

I am designing a custom widget which is basically a QGroupBox holding a configurable

  • 0

I am designing a custom widget which is basically a QGroupBox holding a configurable number of QCheckBox buttons, where each one of them should control a particular bit in a bitmask represented by a QBitArray. In order to do that, I added the QCheckBox instances to a QButtonGroup, with each button given an integer ID:

    def populate(self, num_bits, parent = None):
        """
        Adds check boxes to the GroupBox according to the bitmask size
        """
        self.bitArray.resize(num_bits)
        layout = QHBoxLayout()

        for i in range(num_bits):
            cb = QCheckBox()
            cb.setText(QString.number(i))
            self.buttonGroup.addButton(cb, i)
            layout.addWidget(cb)
        self.setLayout(layout)

Then, each time a user would click on a checkbox contained in self.buttonGroup, I’d like self.bitArray to be notified so the corresponding bit in the array can be set/unset accordingly. For that I intended to connect QButtonGroup’s buttonClicked(int) signal to QBitArray’s toggleBit(int) method and, to be as pythonic as possible, I wanted to use new-style signals syntax, so I tried this:

self.buttonGroup.buttonClicked.connect(self.bitArray.toggleBit)

The problem is that buttonClicked is an overloaded signal, so there is also the buttonClicked(QAbstractButton*) signature. In fact, when the program is executing I get this error when I click a check box:

The debugged program raised the exception unhandled TypeError
"QBitArray.toggleBit(int): argument 1 has unexpected type 'QCheckBox'"

which clearly shows the toggleBit method received the buttonClicked(QAbstractButton*) signal instead of the buttonClicked(int) one.

So, the question is, how can I specify the signal connection, using new-style syntax, so that self.bitArray receives the buttonClicked(int) signal instead of the default overload – buttonClicked(QAbstractButton*)?

EDIT: The PyQT’s New-style Signal and Slot Support documentation states you can use pyqtSlot decorators to specify which signal you want to connect to a given slot, but that is for a slot you are creating. What to do when the slot is from a “ready made” class? Is the only option subclassing it and then reimplementing the given slot with the right decorator?

  • 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-06T10:33:41+00:00Added an answer on June 6, 2026 at 10:33 am

    While browsing for related questions I found this answer to be exactly what I needed. The correct new-style signal syntax for connecting only QButtonGroup’s buttonClicked(int) signal to QBitArray’s toggleBit(int), ignoring the other overloaded signatures, involves specifying the desired type in brackets, like this:

    self.buttonGroup.buttonClicked[int].connect(self.bitArray.toggleBit)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on Expression Blend and I'm currently designing a custom control which has
I'm currently designing a custom tab control class which derives from System.Windows.Forms.Control. The problem
I am working in android. i am designing a custom dialog in which there
I'm designing a game with a custom keyboard(Rows of buttons) I want the buttons
I am designing a custom navigation menu, which you can see in it's current
I am designing a custom button with that requires me to overlay a UIButton
I am designing a custom HTML helper and I would like to execute Html.ActionLink
I am creating a custom Table by designing my own UITableViewCell in Xcode and
Defining custom components in Facelets is easy and quick but there's one thing I
Designing forms has always been fun, but getting them to send email on the

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.