[Qt-interest] Detecting mouseRelease w/o subclassing

Andre Somers andre at familiesomers.nl
Fri Jul 9 10:19:40 CEST 2010


On 9-7-2010 5:23, Paul England wrote:
> This is driving me up the wall.  I can't for the life of me figure out
> why there are multiple signals which denote th estart of a mouse event,
> but not a single one for the end?   Great.
>
> Long story short:
> QHeaderView::sectionResized( int, int, int ) is signalled way too much.
> If I want to resize a section (and actually other sections based on that
> one) the signal is called multiple times for each true resize.  I have a
> nice subclassed QHeaderView, and when I reimplement mouseReleaseEvent()
> and emit my own signal, it works, except there's some magic going on in
> the base class's mouseReleaseEvent() (which ensures everything is the
> right size).  So, in mine, I get this left over crap on the right side,
> which is very unsightly.
>    
So, I conclude you did not call the superclass's implementation from 
your subclass? That usually fixes such issues.
If you don't want to subclass, but still listen in on the events, use an 
event filter. See QObject::eventFilter and setEventFilter for more 
information.
> So, other than a QTimer (which would be pretty ghetto) and
> reimplementation which I've found to be far too cumbersome for something
> so simple, is there anything else I can check to tell if the mouse
> button is still depressed when my slot is called?
>    
QApplication::mouseButtons return that, as Scott remarked.

André

-- 
Nokia Certified Qt Developer.
Interested in Qt related job offers or freelance Qt consulting work.




More information about the Qt-interest-old mailing list