CWND to QWidget* => QWindow::fromWinId(), access violation error
-
Hello,
I'm using MFC to build a GUI , I recently integrated Qt5.12 library in my project. I need to connect a CWND pointer to QWidget pointer. To do so, I refered to this post : https://forum.qt.io/topic/76525/cwnd-to-qwidgetBut I am getting an eccess violation error when I call QWindow::fromWinId() function.
My code is:
CWnd* cwnd= GetDlgItem(IDC_STATIC);
HWND hWnd = cwnd->GetSafeHwnd();
WId externalWindow = (WId)hWnd;
QWindow *myWindow = QWindow::fromWinId(externalWindow);Does anyone know why I could get this error and how to fix it?
Thank you,
Emmanuel
-
Hi and welcome to devnet,
Did you check that the values you are getting are valid ?
-
Sorry, I don't remember that one.
However, I did just remember that there might be something useful for you: the QtWinMigrate module. It might allow you to build what you need.
Hope it helps