Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Embed QDialog window into win32

Embed QDialog window into win32

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MassiM Offline
    MassiM Offline
    Massi
    wrote on last edited by
    #1

    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!

    Software Design Engineer at Ford - Canada

    A 1 Reply Last reply
    0
    • MassiM Massi

      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!

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #3

      @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.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

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

        Hope it helps

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • MassiM Massi

          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!

          A Offline
          A Offline
          ambershark
          wrote on last edited by
          #3

          @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.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          1
          • MassiM Offline
            MassiM Offline
            Massi
            wrote on last edited by
            #4

            @ambershark Many thanks you were right!!!!

            Software Design Engineer at Ford - Canada

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved