[PyKDE] Emit a signal from a QCheckTableItem

Daryl Dusheiko daryld at magtech.com.au
Wed Apr 26 07:44:34 BST 2006


Hi,

I would like to add a CheckBox to a cell in a QTable that sends a signal 
when the check box is clicked. The existing QCheckTableItem does not 
emit any signals.

I've specialised the class from both the QTableItem and QObject classes. 
When I create the new class and add the item to the table I get the 
following error:

   File "/home/daryld/BurninTest/BurninTestDialog.py", line 29, in __init__
29, in __init__   
    QTableItem.__init__(self, table, edittype, text)
 TypeError: argument 2 of QObject() has an invalid type


My class looks as follows:
class CheckBoxTableItem(QObject, QTableItem):
    def __init__(self, table, edittype, text):
        QObject.__init__(self)
        QTableItem.__init__(self, table, edittype, text)  # !!! THIS IS 
LINE 29 !!!
        self.checkbox = None

    def setContentFromEditor(self, w):
        if self.checkbox:
            self.setText(self.checkbox.text())

    def createEditor(self):
        self.checkbox = QCheckBox(self.table().viewport())
        self.checkbox.connect(self.checkbox, SIGNAL("clicked()"), 
self.__Clicked)
        self.checkbox.setText(self.text())
        self.checkbox.show()
        return self.checkbox

    def __Clicked(self):
        self.emit(PYSIGNAL("Clicked()"), ())


The code where the object is created and is added to the table looks as 
follows:
        checkItem = CheckBoxTableItem(self.testStatusTable, 
QTableItem.Always, "Start")
        self.connect(checkItem, SIGNAL("clicked()"), 
self.__CheckItemClicked)

        self.testStatusTable.setItem(row, 0, checkItem)

Please could someone help me get rid of this error or suggest another 
way to get a signal when I click a check box in a table cell.


Cheers

Daryl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: daryld.vcf
Type: text/x-vcard
Size: 237 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060426/8a1421a5/daryld.vcf


More information about the PyQt mailing list