Embed QDialog window into win32



  • Good day,
    I don't know if I'm in the right forum but I'll be glad if someone could please help me that will be awesome.
    I'm stuck on an integration issue between Win32 app and Qt application. I'm trying to embed a QDialog window into a Win32 app built with visual studio 2012.
    Let's assume a simple QDialog that has QGraphicsView which contains a couples of items (image, button, ...). When I invoke the dialog by exec() function, it pop up the window and display my QGraphicsView with its items without problem.
    Now, I want to put my QDialog window as a child of my Win32 app so I will be able to call it from there by the following code:

    QDialog* m_Dialog = new QDialog();
    // ...
    // ad Qgraphics view + add widget
    //...
    HWND hdialog		= (HWND)m_Dialog->winId();
    HWND window		= CWnd::FromHandle(hdialog)->GetSafeHwnd();
          if (::IsWindow(window) && ::IsWindow(m_hWnd))  //m_hWnd = pointer to a parent
          {
             // Reparent the window to us
             ::SetParent(window, m_hWnd);
    			
             DWORD style = ::GetWindowLong(window, GWL_STYLE);
             style &= ~(WS_POPUP|WS_CAPTION);
             style |= WS_CHILD;
    
             ::SetWindowLong(window, GWL_STYLE, style);
             ::ShowWindow(window, SW_SHOW);
    
             CRect rcCli;
             GetClientRect(rcCli);
    
             // Move it
             ::MoveWindow(window, 0, 0, rcCli.Width(), rcCli.Height(), TRUE);
    	 ::UpdateWindow(m_hWnd);
          }
    

    The problem is my Dialog window is shown within win32 app but my QGraphicsView is totally empty? and I don't catch it why?

    Thanks in advance!


  • Lifetime Qt Champion

    Hi,

    There might be something for you in the QtWinMigrate module from the QtSolutions repository.

    Hope it helps



  • @Massi It's empty because you don't have an event loop. That is what the exec() call does. Since you don't have that none of Qt's messages can be processed. Thus no drawing, or any other signal handling.



  • @ambershark Many thanks you were right!!!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.