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. MFC CWnd as child window of QWidget
Forum Updated to NodeBB v4.3 + New Features

MFC CWnd as child window of QWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 444 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    I'm porting a large application from MFC to Qt.

    I've replaced the main window with a QMainWindow, but I am at a loss as how I can have MFC windows as children.

    I thought initially that QWinHost was the tool for this, but AFAICT it just isn't intended to do that.

    Having QWidgets as a child of a CWnd I understand: I just use a QWinWidget as an MFC CWnd that also happens to be a QWidget, so can host another QWidget.

    So how do I get a QWidget to host a CWnd ? Or do I only convert the main window as the very last stage AFTER all MFC windows and dialogs have been converted to QWidgets?

    Thanks
    David

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      What do you mean by
      "MFC windows as children."
      You mean free windows, belonging to your app ?
      OR now use Windows as widgets ?
      Or you call components from MFC for windows also ? ( as the win API also does)

      Try with
      WId externalWindow = (WId)FindWindow(NULL, L"Untitled - Notepad"); // only if external.
      QWindow *myWindow = QWindow::fromWinId(externalWindow);
      QWidget *myWidget = QWidget::createWindowContainer(myWindow);

      But on windows, it has issues with keys and mouse wheel but clicking did work fine.

      1 Reply Last reply
      0
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        I mean having MFC windows inside a widget.

        So I might have a layout (e.g. a grid) that has both Widgets and MFC windows in it.

        D.

        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