Forum > QT
How do I obtain the X11 or MS Windows handle of a QT window object?
vfclists:
--- Quote from: zeljko on January 19, 2024, 05:18:52 pm ---TWinControl.handle = TQtWidget, if you need QWidget then
TQtWidget(Handle).Widget.
eg if you want to call Qt directly from your app:
QWidget_setVisible(TQtWidget(Handle).Widget, True);
if you want to directly access QPainter inside paint event then:
TQtDeviceContext(Canvas.Handle).Widget
eg
WideStr := 'MyText';
QPainter_drawText(TQtDeviceContext(Canvas.Handle).Widget, @WideStr);
--- End quote ---
Thanks. I managed to get it working.
I embedded an Emacs session into TPanel and got it working.
The problem now is Emacs doesn't get resized when the panel is resized, and I think the way to do that would be to get the window handle of the embedded session and ask X11 or Windows, or perhaps QT the resize.
Is there some way for the TPanel to get the handle of the embedded Emacs?
Maybe there is another type of control that can get any items placed inside to behave like Lazarus own alClient child controls?
MarkMLl:
--- Quote from: vfclists on January 20, 2024, 04:42:04 pm ---The problem now is Emacs doesn't get resized when the panel is resized, and I think the way to do that would be to get the window handle of the embedded session and ask X11 or Windows, or perhaps QT the resize.
--- End quote ---
xref to final para of https://forum.lazarus.freepascal.org/index.php/topic,65913.msg502935.html#msg502935
That sort of thing is specifically why I added resize monitoring to the IDE's console window: I was working on something that wanted an embedded shell. Looking at my notes in pseudoterminaldlg.pp, at least in Linux there's an ioctl() involved which, if sent to a terminal (a pty?) results in the kernel sending the appropriate signal to the app(s) sunning in it.
MarkMLl
zeljko:
--- Quote from: vfclists on January 20, 2024, 04:42:04 pm ---
--- Quote from: zeljko on January 19, 2024, 05:18:52 pm ---TWinControl.handle = TQtWidget, if you need QWidget then
TQtWidget(Handle).Widget.
eg if you want to call Qt directly from your app:
QWidget_setVisible(TQtWidget(Handle).Widget, True);
if you want to directly access QPainter inside paint event then:
TQtDeviceContext(Canvas.Handle).Widget
eg
WideStr := 'MyText';
QPainter_drawText(TQtDeviceContext(Canvas.Handle).Widget, @WideStr);
--- End quote ---
Thanks. I managed to get it working.
I embedded an Emacs session into TPanel and got it working.
The problem now is Emacs doesn't get resized when the panel is resized, and I think the way to do that would be to get the window handle of the embedded session and ask X11 or Windows, or perhaps QT the resize.
Is there some way for the TPanel to get the handle of the embedded Emacs?
Maybe there is another type of control that can get any items placed inside to behave like Lazarus own alClient child controls?
--- End quote ---
How exactly you embed emacs window into TPanel ? Have you used qt or x11 directly ?
vfclists:
--- Quote from: zeljko on January 20, 2024, 10:42:55 pm ---
How exactly you embed emacs window into TPanel ? Have you used qt or x11 directly ?
--- End quote ---
This is the code for getting the panel's window handle.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.btnPanelHandleClick(Sender: TObject);begin edtWinHandle.Text := IntToStr(QWidget_winId(TQtWidget(pnlEmacsParent.Handle).Widget));end;
This the Emacs command, with window handle 102760473
--- Code: Bash [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---emacs --parent-id 102760473 --with-profile doom01
zeljko:
You have Qt routines to embedd foreign window, maybe that works better. I cannot remember exactly but long time ago way example here on forum howto embedd x11 window via starting it's process via TProcess.
Check this two routines: https://doc.qt.io/qt-6/qwidget.html#createWindowContainer and https://doc.qt.io/qt-6/qwindow.html#fromWinId.
Navigation
[0] Message Index
[*] Previous page