I've got a Widget (QTabeleWidget, QLabels and some QButtons). It was build in Qt-Designer. And now I have to implement some things. For that I need the mousePressEvent. Usually I would write a subclass and write something like this:
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
print "left"
else:
print 'right'
But I don't know how to do that for a Widget created in the Designer. I need it for the QTabeleWidget. Hope someone can help me. I tried to solve the problem with the help of google, but without success. This site helped me many times, so I thought I'll give it a shot and ask.
With PyQt there are three different ways to work with forms created in designer:
Single Inheritance:
Multiple Inheritance:
Dynamically Generated:
For (3) above, you'll end up with an instance of whatever base type you specified for your form. You can then override your
mousePressEvent
as desired.I'd recommend you take a look at section 13.1 in the PyQt4 reference manual. Section 13.2 talks about the
uic
module.