<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks for your quick reply. I thought that it was possible to have
multiple inheritance in Python.<br>
<br>
My original problem was to have a checkbox item in a table cell which
could emit a signal when clicked. What I've done is to make a QObject
data member as part of my CheckBoxItem class. Is this the only way to
get this class to emit a signal when clicked?<br>
<br>
My class looks as follows:<br>
class CheckBoxTableItem(QTableItem):<br>
def __init__(self, parent, table, text):<br>
QTableItem.__init__(self, table, QTableItem.Always, text)<br>
self.emitter = QObject(parent)<br>
self.checkbox = None<br>
<br>
def setContentFromEditor(self, w):<br>
print 'CheckBoxTableItem::setContentFromEditor ' #DFD<br>
if self.checkbox:<br>
self.setText(self.checkbox.text())<br>
<br>
def createEditor(self):<br>
print 'CheckBoxTableItem::createEditor ' #DFD<br>
self.checkbox = QCheckBox(self.table().viewport())<br>
self.checkbox.connect(self.checkbox, SIGNAL("clicked()"),
self.__Clicked)<br>
self.checkbox.setText(self.text())<br>
self.checkbox.show()<br>
return self.checkbox<br>
<br>
def __Clicked(self):<br>
self.emitter.emit(PYSIGNAL("Clicked()"), ())<br>
<br>
It's created as follows:<br>
checkItem = CheckBoxTableItem(self, self.testStatusTable,
"Start")<br>
self.connect(checkItem.emitter, PYSIGNAL("Clicked()"),
self.__CheckItemClicked)<br>
<br>
self.testStatusTable.setItem(row, 0, checkItem)<br>
<br>
Cheers<br>
<br>
Daryl<br>
<br>
<br>
<br>
Phil Thompson wrote:
<blockquote cite="mid200604260935.57088.phil@riverbankcomputing.co.uk"
type="cite">
<pre wrap="">On Wednesday 26 April 2006 7:44 am, Daryl Dusheiko wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap=""><!---->
You can't inherit from more than one wrapped class at a time.
Phil
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit <a class="moz-txt-link-freetext" href="http://www.messagelabs.com/email">http://www.messagelabs.com/email</a>
______________________________________________________________________
</pre>
</blockquote>
</body>
</html>