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 Windows program within Qt program
QtWS25 Last Chance

Embed Windows program within Qt program

Scheduled Pinned Locked Moved Unsolved General and Desktop
embedwindows
6 Posts 3 Posters 3.6k Views
  • 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.
  • J Offline
    J Offline
    JGrider
    wrote on last edited by
    #1

    Hi, I am trying to embed a program that runs on windows (let's say Calculator) into my Qt program.

    I already know how to launch it as an external program by running the following:

    QProcess *proc = new QProcess(this);
    proc->start("C:\\Windows\\SysWOW64\\calc.exe");
    

    But that only launches it as if I had launched the program manually from windows itself. I would like to have the program sit inside my Qt program and run within. It should also close and minimize along with the main Qt window.

    I've been looking around online and I've come across this information: https://docs.huihoo.com/qt/solutions/4/qtwinmigrate/winmigrate-win32-in-qt-example.html
    But I don't understand what I'm looking at there.

    If someone could please explain how I can get this done I would greatly appreciate it!

    JonBJ 1 Reply Last reply
    0
    • J JGrider

      Hi, I am trying to embed a program that runs on windows (let's say Calculator) into my Qt program.

      I already know how to launch it as an external program by running the following:

      QProcess *proc = new QProcess(this);
      proc->start("C:\\Windows\\SysWOW64\\calc.exe");
      

      But that only launches it as if I had launched the program manually from windows itself. I would like to have the program sit inside my Qt program and run within. It should also close and minimize along with the main Qt window.

      I've been looking around online and I've come across this information: https://docs.huihoo.com/qt/solutions/4/qtwinmigrate/winmigrate-win32-in-qt-example.html
      But I don't understand what I'm looking at there.

      If someone could please explain how I can get this done I would greatly appreciate it!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @JGrider
      This kind of question gets asked often. You can't actually "embed" an existing, external application into a Qt program/window (or anything else). Things have to be written to embed if the designers want it to embed.

      The link you mention would allow a native Windows window to be used in a Qt app. But you can't make calc run it that window, so it doesn't help what you're looking for, I'm afraid.

      J 1 Reply Last reply
      2
      • JonBJ JonB

        @JGrider
        This kind of question gets asked often. You can't actually "embed" an existing, external application into a Qt program/window (or anything else). Things have to be written to embed if the designers want it to embed.

        The link you mention would allow a native Windows window to be used in a Qt app. But you can't make calc run it that window, so it doesn't help what you're looking for, I'm afraid.

        J Offline
        J Offline
        JGrider
        wrote on last edited by
        #3

        @JonB
        What do you mean by a native Windows window? If all you mean is that I can host it inside without actually changing anything the external program does, that's fine. I don't need to change any of the workings of it.

        JonBJ 1 Reply Last reply
        0
        • J JGrider

          @JonB
          What do you mean by a native Windows window? If all you mean is that I can host it inside without actually changing anything the external program does, that's fine. I don't need to change any of the workings of it.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @JGrider
          It gives you access to a Windows native window handle, HWND, from your code.

          QWinHost exists to provide a QWidget that can act as a parent for any native Win32 control.
          .
          Applications moving to Qt may have custom Win32 controls that will take time to rewrite with Qt. Such applications can use these custom controls as children of QWinHost widgets. This allows the application's user interface to be replaced gradually.
          ...
          The Qt/MFC Migration Framework tool assists in the migration of existing Win32 or MFC applications to the Qt toolkit.

          You don't have a Win32 control. You have an external application, with its own window. It's not interested in yours.

          Did you notice that what you are looking at is from 2009...?

          J 1 Reply Last reply
          0
          • JonBJ JonB

            @JGrider
            It gives you access to a Windows native window handle, HWND, from your code.

            QWinHost exists to provide a QWidget that can act as a parent for any native Win32 control.
            .
            Applications moving to Qt may have custom Win32 controls that will take time to rewrite with Qt. Such applications can use these custom controls as children of QWinHost widgets. This allows the application's user interface to be replaced gradually.
            ...
            The Qt/MFC Migration Framework tool assists in the migration of existing Win32 or MFC applications to the Qt toolkit.

            You don't have a Win32 control. You have an external application, with its own window. It's not interested in yours.

            Did you notice that what you are looking at is from 2009...?

            J Offline
            J Offline
            JGrider
            wrote on last edited by
            #5

            @JonB
            Ok, I think I get what you're saying now. Thanks for clearing that up for me!

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              There is a way to force an external window to become part of a widget, but the API isn't really meant to be used this way and there are multiple issues: https://bugreports.qt.io/browse/QTBUG-45275

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              4

              • Login

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