Hi all, I am using PyQt.

In my UI, I have created a QDialogButtonBox that houses 3 buttons - 'Add', 'Remove' and 'Clear' and I assigned their roles as follows:
Qt Code:
  1. # List widget 01
  2. self.widget_01_btns = QtGui.QDialogButtonBox()
  3. self.widget_01_btns.addButton('Add', QtGui.QDialogButtonBox.AcceptRole)
  4. self.widget_01_btns.addButton('Remove', QtGui.QDialogButtonBox.RejectRole)
  5. self.widget_01_btns.addButton('Clear', QtGui.QDialogButtonBox.ResetRole)
To copy to clipboard, switch view to plain text mode 

As I will be having another same set of QDialogButtonBox, I thought it will be a good idea for them to 'share' the functions so that there is no need for me to write it twice.
However when I tried to connect the signals, the signal assigned for 'Clear' will be called whenever either 'Add' or 'Remove' button is used.

I tried another method that I found online, but upon using it, I got this error instead -
`AttributeError: 'NoneType' object has no attribute 'clicked'`

Qt Code:
  1. # For widget 01
  2. self.widget_01_btns.accepted.connect(lambda:self.add_objects(self.widget01_list))
  3. self.widget_01_btns.rejected.connect(lambda:self.remove_objects(self.widget01_list))
  4. # This is called in conjunction whenever either 'Add' or 'Remove' button is clicked
  5. self.widget_01_btns.clicked.connect(lambda:self.clear_objects(self.widget01_list))
  6.  
  7. # This is the online method I found but it is not working...
  8. # self.widget_01_btns.button(QtGui.QDialogButtonBox.Reset).clicked.connect(lambda:self.clear_objects(self.widget01_list))
To copy to clipboard, switch view to plain text mode 


Any pointers?