Skip to content

Using EventFilters #204

Answered by rcalixte
emad-elsaid asked this question in Q&A
Apr 20, 2025 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

I'm working on a precise example that should be of help (see below) but the long and short of it is that my understanding is that you would create a new QObject type in addition to your other object (let's say a QLabel in this instance), no need for a struct:

o := qt.NewQObject()

You would then use o.OnEventFilter() to set the filter for the newly-constructed object and then on your original QObject-derived instance, call InstallEventFilter, so the steps would be effectively:

l := qt.NewQLabel2()
o := qt.NewQObject()

o.OnEventFilter(func(super func(watched *qt.QObject, event *qt.QEvent) bool, watched *qt.QObject, event *qt.QEvent) bool {
  // do your things here
}

l.InstallEventFilter(o)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@emad-elsaid
Comment options

@rcalixte
Comment options

Answer selected by emad-elsaid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants