Forum > QT
How do I obtain the X11 or MS Windows handle of a QT window object?
vfclists:
I'm trying to embed forms and windows of other programs into a QT based panel, and they require the a window ID for the panel.
MarkMLl:
I might be able to provide a partial answer for X11.
I have a monitoring program here which can detect if something that looks like an exception popup is on the screen, and alert a monitoring program to- on rare occasions- wake me up in the middle of the night. Looking at the code, I ran wmctrl -lp to get a list of titles, after which I filtered looking for candidate problems. So I suggest that in the X11 case it boils down to working out what API wmctrl is using... which might not be a simple job since I find all of the Window Manager stuff to be pretty impenetrable.
The predecessor program was written for Win-32 in the W2K era but in practice only used NT-era APIs, I've got a very vague recollection that I used the windowstation (?) API to scan multiple desktops and (presumably) filtered on names etc. after that.
HTH in some small way.
MarkMLl
CCRDude:
I must admit I used google... and it looks quite easy:
https://stackoverflow.com/questions/22652592/getting-the-hwnd-of-a-widget-in-qt
--- Quote ---You can use QWidget::winId() to get the HWND associated with a widget.
--- End quote ---
vfclists:
--- Quote from: CCRDude on January 19, 2024, 04:11:08 pm ---I must admit I used google... and it looks quite easy:
https://stackoverflow.com/questions/22652592/getting-the-hwnd-of-a-widget-in-qt
--- Quote ---You can use QWidget::winId() to get the HWND associated with a widget.
--- End quote ---
--- End quote ---
Yes, but that leaves how to get the winId of the TWinControl in question within FreePascal.
I am sure I've done it before, I just can't remember the sample program I did it in.
zeljko:
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);
Navigation
[0] Message Index
[#] Next page