Qt Python radiobutton: activate event

Threader Slash threaderslash at gmail.com
Wed Nov 18 01:12:31 EST 2009


Hi Everybody,

I am developing a project for one customer, where the design has a radio
button with exclusive options.

Here is a piece of the code that runs and show two nice radio buttons:

        self.performGroupBox = QtGui.QGroupBox(self.centralwidget)
        self.performGroupBox.setGeometry(QtCore.QRect(50, 20, 181, 121))
        self.performGroupBox.setObjectName("performGroupBox")

        self.consultRadioButton = QtGui.QRadioButton(self.performGroupBox)
        self.consultRadioButton.setGeometry(QtCore.QRect(40, 30, 84, 18))
        self.consultRadioButton.setObjectName("consultRadioButton")

        self.insertRadioButton = QtGui.QRadioButton(self.performGroupBox)
        self.insertRadioButton.setGeometry(QtCore.QRect(40, 60, 84, 18))
        self.insertRadioButton.setObjectName("insertRadioButton")

it just looks like:

    perform:
        () Consult
        () Insert


The point here is, how to know what choice was marked: "consultRadioButton"
or "insertRadioButton"?

Here is a sample on trying to get this information:

        if self.consultRadioButton.isChecked():
            self.call_Consult()
        if self.insertRadioButton.isChecked():
            self.call_Insert()

But it didn't do anything when the radiobutton is chosen.

Otherwise, using connect should be another option:

        QtCore.QObject.connect(self.consultRadioButton,
QtCore.SIGNAL("currentIndexChanged(QString)"), self.call_Consult)
        QtCore.QObject.connect(self.insertRadioButton,
QtCore.SIGNAL("currentIndexChanged(QString)"), self.call_Insert)

But it didn't work either.

What is missing here... Any suggestion?

All comments are highly welcome and appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091118/65534f57/attachment.html>


More information about the Python-list mailing list