Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Create my widget from HWND?
Taytoo last edited by
I created a widget (MyWidget) window in QT Designer w/classes, it will show as an independent window on desktop without any parent, but I have to use an existing HWND to create the instance of MyWidget. Is it possible?
but I have to use an existing HWND to create the instance of MyWidget
Sorry, but that doesn't make sense. You don't create widgets or windows using a HWND. HWND is a handle that you can get from an existing window. It's like a pointer in C++. You don't use pointers to create instances of classes. You can get a pointer to an existing instance.
So if you have an existing HWND that means you have a native window. You can embed a widget inside that native window if you want. You would do that by getting the widget's HWND (using winId()) and then use native SetParent() to make the widget child of that existing window.
Is it possible?
Not easily and involves some really nasty tricks. My advice: don't! See what @Chris-Kawa wrote, try to work around the issue. Why do you require this anyway?