Hi guys,
I've a problem calling a 'parent' PyQt4 method from inside an object that inerits it.
Here is the code:
import sys
from PyQt4 import QtCore, QtGui
class ItiaQPushButton(QtGui.QPushButton):
def __init__(self, txt):
super(ItiaQPushButton, self).__init__("Hello")
print super(ItiaQPushButton, self).__doc__
#QtGui.QPushButton.setText("BO")
def setText2(self, txt):
self.setText(txt)
#super(ItiaQPushButton, self).setText("PROVA")
class Window(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
flowLayout = QtGui.QHBoxLayout()
b = ItiaQPushButton("Test")
b.setText2(self.tr("qwe"))
flowLayout.addWidget(b)
self.setLayout(flowLayout)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mainWin = Window()
mainWin.show()
sys.exit(app.exec_())
This works but if I try to uncomment the command 'super(ItiaQPushButton, self).setText("PROVA")' it doesn't work anymore. I would like to change the name 'setText2' into 'setText' but without calling setText method through 'super' command I can't call the inherited 'setText' method.
I hope someone can help me,
Thank you
Matteo