[PyQt] QCheckBox problem

Doug Hackworth doug.hackworth at vanderbilt.edu
Mon Jan 5 01:30:41 GMT 2009


Greetings.  This should be an easy one for someone to answer.

Simple situation:  I have a QCheckBox on a main window along with other widgets, 
but mysteriously it won't do anything.  Since all my other widgets (buttons, 
mainly) do what they're supposed to, I suspect I am using the QCheckBox 
incorrectly.  It's the first time I've tried using one.

I am attempting to connect the checkbox's "toggled()" signal to a slot with this 
line:

<code>
QtCore.QObject.connect(self.ui.checkMyCheckbox, QtCore.SIGNAL("toggled()"), 
self.MyCheckboxSlotFunction)
</code>

Here is the slot I have defined for it:

<code>
def CheckMultiMask(self):
         sys.stdout.write("checkbox toggleded\n")
         if (self.ui.checkMyCheckbox.isChecked()):
             sys.stdout.write("it's checked\n")
</code>

When the window loads, however, I can click on the QCheckBox all I want, to no 
avail.  Also, the application object doesn't complain when it loads, and I know 
it's getting to the connect() invocation quoted above...  I just don't know why 
the slot function doesn't seem to ever be invoked.  And again, my other widgets 
with signals/slots connected by me (in a manner like that above) are behaving as 
expected.

Any thoughts from the experts?  I'll be happy to provide further information on 
context if it's useful.

BTW, I'm using Ubuntu 7.10 and the following versions of PyQt / Qt:
$ pyuic4 --version
Python User Interface Compiler 4.3 for Qt version 4.3.2

(The MainWindow was constructed with Qt Designer by way of pyuic4.)

Thanks,
Doug



More information about the PyQt mailing list