Recognize set/lose Focus-Event in QWindow

499 Views Asked by At

I´ve created a Qt-Quick Combo-Box that, when it will be pressed, opens a QWindow, in which I show the content within a TableView. The problem is, the focus on the TableView can´t be set.

So first question is: How can I set the Focus on my TableView (which is hosted inside my QWindow)?

Furthermore, I have to get the event, if the user clicks beside the QWindow or outside the Application. That means the focus was changed and I can close my QWindow.

So second question is: How can I get the information, that the TableView lost the focus?

Thanks in advance.

1

There are 1 best solutions below

1
On

For from QWidget derived classes:

To set a focus use setFocus.

To recognize that the focus has been los, you can derive the class and override focusOutEvent or write an eventfilter.