[PyKDE] Emit a signal from a QCheckTableItem

Phil Thompson phil at riverbankcomputing.co.uk
Wed Apr 26 09:35:57 BST 2006


On Wednesday 26 April 2006 7:44 am, Daryl Dusheiko wrote:
> 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.

You can't inherit from more than one wrapped class at a time.

Phil




More information about the PyQt mailing list