[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Re: How to override mousePressEvent for an existing
From:       "Hans-Peter Jansen" <hpj () urpla ! net>
Date:       2009-07-30 9:32:52
Message-ID: 200907301132.52813.hpj () urpla ! net
[Download RAW message or body]

Am Donnerstag, 30. Juli 2009 schrieb Dov Grobgeld:
> I wrote:
> > [stuff deleted]
> >
> >
> > This is actually related to another even more fundamental question, why
> > is the difference between overriding and connecting? I.e. why is
> > "clicked" a signal and "mousePressEvent" an overrided virtual. Why
> > can't they both be signals, in which case the problem I describe
> > wouldn't happen? (That's how it works in Gtk, btw.)
>
> I realized that the wording above is both unfortunate and wrong. I
> understand that there is a need for virtual functions, and Gtk indeed
> provides them as well. But what is less clear to me is why there is a
> distinction between "clicked" and "mousePressEvent", and why they are
> implemented differently? Anyhow, that has nothing to do with the Py part
> of PyQt which simply reflects the underlying API.

Because, conceptually, the clicked signal is generated in the 
mousePressEvent, thus the events are low level notifications, and signals 
the standard "high level" way of using this functionality (from apps 
perspective). 

Since there is no rightClicked signal available, you will want to look into 
QWidget.eventFilter() et.al. 

A cleaner approach would be to subclass a button widget, override 
mousePressEvent and generate the missing signal there. It's quite easy to 
add simple widgets to designer (nowadays). 

Note, the average user does not expect right click functionality from 
buttons, this is why such a signal does not exist in the first place. Thus 
your users might never discover it..

Pete
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic