[Lazarus] Embed other application window with qt5

Luca Olivetti luca at wetron.es
Tue Jun 9 09:08:43 CEST 2020

El 7/6/20 a les 11:51, Luca Olivetti via lazarus ha escrit:
> Hello,
> I'd like to embed another application window[*] in my application.
> I found this code
> https://stackoverflow.com/questions/7611103/embedding-window-into-another-process#7612436 
> and it works. Since my application should run under windows that should 
> be enough, but I prefer to do my testing under Linux, so I'd like a 
> solution for the qt5 widgetset.
> I tried this code
> procedure TForm1.Button1Click(Sender: TObject);
> var kk:QWindowH;
>    cc: QWidgetH;
> begin
>    kk:=QWindow_fromWinID(StrToInt64(Edit1.text));
>    QWindow_setFlags(kk,QtFramelessWindowHint);
>    cc:=QWidget_createWindowContainer(kk);
>    QWidget_setParent(cc,TQtWidget(Self.Handle).Widget);
> end;

I also tried

    QWidget.setParent(cc, TQTMainWindow(handle).GetContainerWidget)


    QWidget.setParent(cc, TQTMainWindow(handle).Widget)

as well as TQTWidget(panel1.handle).widget

but nothing works (the other application disappears but it doesn't show 
on my form/panel)

> and, while the other application window disappears, I don't see it in my 
> form (it's still running though).
> I tried to find some clues in the mplayer control but it doesn't work 
> with qt (I tried to adapt it with no success), besides it just instructs 
> mplayer to embed itself in a control.
> [*] actually I need to embed a browser, but none of the alternatives in 
> https://wiki.freepascal.org/Webbrowser work:
> - turbopower is too limited
> - I didn't try qtWebkit but it seems qt only

I tried, qt4 only, so no qt5

> - geckoport has been discontinued
> - fpCEF3 is old and couldn't make it work[**]
> - CEF4Delphi is windows only at the moment
> but playing with userChrome.css I could embed firefox as an external 
> application.

it's tough (firefox is special since firefox.exe isn't directly the 
owner of its window but it spawns other instances that in turn show the 
window and it always shows the window borders, no matter what api you 
try to avoid that) but I managed to do it under windows.


Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007

More information about the lazarus mailing list