PDA

View Full Version : How to show application inside another application's window ?



marcvanriet
29th August 2010, 23:56
Hello,

We have a main program written in MFC (Windows) that has buttons to start different actions. Those actions are performed by external programs (.exe's or DLL) that are started by the main program.

The external programs show their user interface INSIDE a window area of the main program. So it looks to the user as if it is all one integrated program. This is accomplished by giving the external programs the windows handle of the main application, and they use that as 'parent' for their main window.

Now I would like to write an external program in Qt that works in the same way. Can it be done in Qt ?

I was thinking of passing the windows handle to the constructor of my QMainWindow, but have no idea how to translate the windows handle to a QWidget pointer.

Best regards,
Marc

ChrisW67
30th August 2010, 01:38
Translating the parent program's Windows window handle in to a QWidget pointer makes no sense unless the parent program is itself a Qt app and even then it doesn't seem to be what you want to do. It sounds like what you want is to re-parent your child Qt app's main widget using whatever Windows API calls the existing external programs use: I guess simply a call to the Windows API SetParent():
http://msdn.microsoft.com/en-us/library/ms633541%28VS.85%29.aspx
(but I'm no Windows API guru).
You should be able to get the Windows window handle for your main widget using QWidget::winId().



SetParent(this->winId(), passedInParentHandle);
The passedInParentHandle will come via a command line argument or somesuch.

sNiff3ls
20th October 2010, 22:06
Hi,

got the same problem but with x.

I'm writing an app for my car-pc and i want to integrate Navit in my application.
How can i do this?

Btw.: In a M$ Windows environment it works like Chris described (at least with .NET).

ChrisW67
20th October 2010, 22:36
XReparentWindow looks like the equivalent