Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install EventFilter on QWidget (qt4.4.3/kde4)

I have a K* window, and within it, a widget which needs the events filtered.

For example I do not want the possibility of clicking it...

How can I do that?

Have I to use eventfilters? In this case, what's the best way?


but my problem is that I can't subclass my widget,because it's a TerminalInterface->widget(), not an object like others :\

like image 835
Giancarlo Avatar asked Oct 15 '22 17:10

Giancarlo


1 Answers

Besides the setEnabled sledgehammer approach in the first answer, there are two other approaches, one of which is to use eventfilters.

The other is to subclass the widget, and then reimplement, say, the mouse* events. Simply leaving them empty will prevent any mouse interaction. So:

MyWidget : public QSomeWidget { Q_OBJECT public: MyWidget(QWidget *parent);

protected: void mousePressEvent(QMouseEvent *) {} .. etc .. };

like image 197
aseigo Avatar answered Oct 19 '22 02:10

aseigo