PDA

View Full Version : How to Know if our Qt application has focus from other No QT application



JuanMO
18th November 2010, 18:18
Hello,

I have a Qt application with severals views ( QWidgets ).
I have a windows service and when same event arrives I must check if any view of the Qt Application has the focus.

At first I try to compare with handles obtained with:

GetForegroundWindow() == FindWindow(L"MyApp",0)

But this fails and FindWindows return NULL.

I think that I miss so set something in QtApplication But I can't Find what could be
Thanks in advance

Juan Manuel

Timoteo
18th November 2010, 19:00
You need to use the lpWindowName parameter instead of lpClassname, since you know what the title of your window is and have no idea what class name Qt might be registering for the window.

JuanMO
18th November 2010, 19:09
Yes you are right, but I have too many windows to check, I imagine that I could set my own Class Name to the Qt application by setting any property to QApplication, but I cant find which one could be.