Hi, I am trying to embed a button per row inside a tableview. My botton are drawing correctly as delegates but are not reacting to any clicks.
Should I be setting flags for this column? so far I have something like: if index.column() == 14: flags |= QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | Qt.ItemIsEnabled return flags This is my delegate, but how do I make the button react to clicks? Thanks, cris class AButton(QtGui.QStyledItemDelegate): mouse_isPressed = False def __init__(self, parent = None): QtGui.QStyledItemDelegate.__init__(self, parent) def boundingRect(self): return QtCore.QRectF(0, 0, 40, 40) def paint(self, painter, option, widget = 0): opt = QtGui.QStyleOptionButton() opt.state = ((QtGui.QStyle.State_Sunken if self.mouse_isPressed else QtGui.QStyle.State_Raised) | QtGui.QStyle.State_Enabled) opt.text = self.text() opt.icon = self.icon() opt.rect = option.rect opt.palette = option.palette QtGui.QApplication.style().drawControl(QtGui.QStyle.CE_PushButton, opt, painter) def text(self): return QtCore.QString("hi") def icon(self): return QtGui.QIcon() def mousePressEvent(self, event): self.mouse_isPressed = True print "HELLO" self.update() def mouseReleaseEvent(self, event): self.mouse_isPressed = False self.update()
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt