[PyQt] qbuttongroup problem

Cucu Ionut cuciferus at gmail.com
Sat Nov 21 15:02:46 GMT 2009


Hi folks!
I made a little script to provide the users an interface for entering 
some data stored in an sqlite file. At some point in my script I have 
some groupbuttons each with 4 radiobuttons created as follows 
class SGA(QtGui.QDialog):
	def __init_(...):
<snip>
	self.greutate=QtGui.QGroupBox("1.Modificari in 
greutate",self.anamneza)
        self.greutateGroup=QtGui.QButtonGroup(self)
        self.greutate.setLayout(self.vlayout0)
        self.greutate.setFlat(True)
        self.g0=QtGui.QRadioButton("Fara modificari sau crestere in \
        greutate",self.greutate)
        self.greutateGroup.addButton(self.g0)
        self.greutateGroup.setId(self.g0,0)
        self.g1=QtGui.QRadioButton("Scadere in greutate minora 
<5%")
        self.greutateGroup.addButton(self.g1)
        self.greutateGroup.setId(self.g0,1)

        self.g2=QtGui.QRadioButton("Scadere in greutate 5-10%")
        self.greutateGroup.addButton(self.g2)
        self.greutateGroup.setId(self.g0,2)
        self.g3=QtGui.QRadioButton("Scadere in greutate 10-15%")
        self.greutateGroup.addButton(self.g3)
        self.greutateGroup.setId(self.g0,3)
        self.g4=QtGui.QRadioButton("Scadere in greutate >15%")
        self.greutateGroup.addButton(self.g4)
        self.greutateGroup.setId(self.g0,4)
        self.vlayout0.addWidget(self.g0)
        self.vlayout0.addWidget(self.g1)
        self.vlayout0.addWidget(self.g2)
        self.vlayout0.addWidget(self.g3)
        self.vlayout0.addWidget(self.g4)
        self.layoutAnamneza.addWidget(self.greutate)
<snip>
and I have about 5 of these buttongroups similary created, but 
when I checked what did the user checked like so:
print self.greutateGroup.checkedId() <--for testing purposes, I get 
-1, and in some other group -4 up to 0, although created the same 
they all yeld different results, only one actually works. Could you 
perhaps give me a hand with this? Thanks!


More information about the PyQt mailing list