Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2020-06

Embed other application window with qt5

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

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;

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
- 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.

Bye

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

Reply by email

Luca Olivetti
to Luca Olivetti

El 7/6/20 a les 11:51, Luca Olivetti via lazarus ha escrit:

- fpCEF3 is old and couldn't make it work[**]

I forgot the [**]: I had to do a couple changes to compile it with fpc 3.2:

diff --git a/cef3types.pas b/cef3types.pas
index 9598487..6cab661 100644
--- a/cef3types.pas
+++ b/cef3types.pas
@@ -2412,7 +2412,7 @@ Type

      // Set to true (1) for thick underline.
      thick: Integer;
    end;

- TCefCompositionUnderlineArray = array[0..(High(Integer) div SizeOf(TCefCompositionUnderline)) - 1] of TCefCompositionUnderline;
+ TCefCompositionUnderlineArray = array[0..0 {(High(Integer) div SizeOf(TCefCompositionUnderline)) - 1 FIXME}] of TCefCompositionUnderline;

    PCefCompositionUnderlineArray = ^TCefCompositionUnderlineArray;
  Implementation

and add ifdefs for LCLQT5

Bye

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

Reply by email

Luca Olivetti
to Luca Olivetti: I'd like to embed another application window[*] in my application. I found this code…

El 7/6/20 a les 11:51, Luca Olivetti via lazarus ha escrit:

Show quoted text 23 lines
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)

and

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)

Show quoted text 14 lines
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

Show quoted text 6 lines
- 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.

Bye

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

Reply by email

zeljko
to Luca Olivetti
Luca Olivetti wrote 20 lines
> 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) and    QWidget.setParent(cc, TQTMainWindow(handle).Widget) as well as TQTWidget(panel1.handle).widget

This works fine here (TPanel on main form, embedded google chrome ):

   AWindow := QWindow_fromWinID(PtrUInt($8600001)); // found id by xwininfo
   AWidget := QWidget_createWindowContainer(AWindow, nil, QtWidget or
QtForeignWindow);
   QWidget_setParent(AWidget, TQtWidget(Panel1.Handle).Widget);
   QWidget_show(AWidget);

You're missing QtForeignWindow flag and QWidget_show() for container widget.

zeljko

Reply by email

Luca Olivetti
to zeljko

El 9/6/20 a les 9:36, zeljko ha escrit:

Show quoted text 33 lines
On 6/9/20 9:08 AM, Luca Olivetti via lazarus wrote: >> 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) > > and > >     QWidget.setParent(cc, TQTMainWindow(handle).Widget) > > as well as TQTWidget(panel1.handle).widget This works fine here (TPanel on main form, embedded google chrome ):   AWindow := QWindow_fromWinID(PtrUInt($8600001)); // found id by xwininfo   AWidget := QWidget_createWindowContainer(AWindow, nil, QtWidget or QtForeignWindow);   QWidget_setParent(AWidget, TQtWidget(Panel1.Handle).Widget);   QWidget_show(AWidget); You're missing QtForeignWindow flag and QWidget_show() for container widget.

Thank you!
I was also missing the QWidget_show call.

Bye

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

Reply by email