0

This is a follow up to an outstanding question, the solution to which appears to be that I have to make my Qt application the child of another application, specifically the active window that has input focus. I need to do this so that my Qt application automatically has input focus, without the user having to first click on it. (This is necessary because the Qt application is launched by a background process.)

I am aware of QWinWidget -- "a Qt widget that can be child of a native Win32 widget". Unfortunately, my application is based on QMainWindow and there is no obvious way to make it derive from QWinWidget.

Community
  • 1
  • 1
Olumide
  • 5,397
  • 10
  • 55
  • 104
  • @AlexanderVX thanks for your reply but I don't really understand your explaination. Can you please try again? – Olumide Nov 22 '14 at 00:13

1 Answers1

0

The solution to which appears to be that I have to make my Qt application the child of another application, specifically the active window that has input focus...

Similar Win32 solutions where the other process app captures some window inside own canvas are usually driven by SetParent API call. Here is one. It works for me with the other process rendering within Qt widget but you need to make it the other way around. How do you get that Qt window handle? Well, for me QWidget::winId() is working even in Qt 5.3 but I lately stumbled upon discussion and a bit confused whether it always works or not. Anyway, you need to get an active window in your Qt app as well before you get its winId() which supposed to be window handle.

P.S. Olumide, please dismiss my initial comment. I thought, the other way around, what app parents what window and it turns out non-Qt takes Qt.

Community
  • 1
  • 1
Alexander V
  • 8,351
  • 4
  • 38
  • 47