Is there a way to remove eventfilter in qt?

I only need an event filter for some time, is there a way to remove it later?

+4
source share
3 answers

Read about how the event system works in Qt here . This is crucial for a basic understanding, especially this paragraph:

The QObject :: installEventFilter () function allows this by setting up an event filter, as a result of which the assigned filter object receives events for the target object in its QObject :: eventFilter () function. The event filter is able to process events before the target is created, which allows it to check and discard events as necessary. An existing event filter can be removed using the QObject :: removeEventFilter () function.

Considering this, you can see that there is a counter part for installEventFilter, which is not surprising that it is called removeEventFilter. Here is the Qt 5 documentation :

void QObject :: removeEventFilter (QObject * obj)

Removes the obj event object object from this object. The request is ignored if such an event filter is not set.

.

(.. eventFilter()).

+7

Qt Docu:

void QObject:: removeEventFilter (QObject * obj)

obj . , .

.

(.. eventFilter()).

+3
+3

Source: https://habr.com/ru/post/1548627/


All Articles