[Qt-interest] Widget transparent to input events
Girish Ramakrishnan
girish at forwardbias.in
Mon Apr 20 10:53:12 CEST 2009
Fabio Dago wrote:
> Hi.
>
> I need to create a particular tree widget in which on top I draw a
> vertical line that user can move frome left to right (and viceversa)
> with the mouse. I need also a particular header for the tree widget,
> that shows a time axis with seconds, minutes etc.. (something like a
> Nero Wave Editor, or other similar software, time axis).
>
> I tried several solutions... Now I want to create a widget, child of
> QTreeWidget, that display the header and the vertical line. The problem
> is that in this way I can't interact with the QTreeWidget with mouse or
> keyboard. I've also reimplement all this method:
>
> void mouseMoveEvent(QMouseEvent *e);
> void mousePressEvent(QMouseEvent *e);
> void mouseReleaseEvent(QMouseEvent *e);
> void wheelEvent(QWheelEvent *e);
> void keyPressEvent(QKeyEvent *e);
> void keyReleaseEvent(QKeyEvent *e);
>
> In the implementation simply I ignore the event (e->ignore()). The event
> may be passsed to the parent widget, but it doesn't work...
>
The above should work. However, an easier technique is to set
Qt::WA_TransparentForMouseEvents attribute in the child widget (you
don't need to reimplement the events).
Girish
More information about the Qt-interest-old
mailing list