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. Opening external application and embed it without opening application out of application
Forum Updated to NodeBB v4.3 + New Features

Opening external application and embed it without opening application out of application

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 2.8k Views 1 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.
  • Thank YouT Offline
    Thank YouT Offline
    Thank You
    wrote on last edited by Thank You
    #1

    How can I embed application like a widget in application that I created.
    I searched about this and found couple of implementation. I don't know anything about this and never read about this. But I want to make something working browser.

    This one is first answer that I found about this topic

    mainwindow.cpp

      QString prog = "C:/Program Files/Mozilla Firefox/firefox.exe";
        QStringList arg;
        arg << "google.com";
        QString workDir = "C:/Program Files/Mozilla Firefox/";
        program->startDetached(prog, arg, workDir, 0);
        WId hWnd = 0;
        while (hWnd == 0)
        {
        hWnd = (WId) FindWindowW(NULL, L"C:/Program Files/Mozilla Firefox/firefox.exe");
        }
        window = QWindow::fromWinId(hWnd);
        container = QWidget::createWindowContainer(window, ui->mdiArea);
        QMdiSubWindow *subWindow = new QMdiSubWindow();
        subWindow->setWidget(container);
        subWindow->setAttribute(Qt::WA_DeleteOnClose);
        subWindow->setWindowTitle("Program 1");
        ui->mdiArea->addSubWindow(subWindow);
        container->show();
    

    In mainwindow.h
    Added necessary headers and these variables in private

    private:
    WId id;
        QProcess *program;
        QWindow *window;
        QWidget *container;
    

    second answer

    mainwindow.cpp

     browserLocation = "C:/Program Files/Mozilla Firefox/firefox.exe";
        mainWidget = new QWidget(this);
        browserWidget = new QWidget(mainWidget);
        mainLayout = new QVBoxLayout(mainWidget);
        QLabel *label = new QLabel(mainWidget);
        label->setText("Is label showing up?");
        proc = new QProcess(this);
        proc->setProgram(browserLocation);
        proc->start();
        qDebug()<<"Started with pid "<<proc->pid();
    
    
        WId id = this->winId();
        QWindow *window = QWindow::fromWinId(id);
        browserWidget = QWidget::createWindowContainer(window,mainWidget);
    
    
    
        mainLayout->addWidget(label);
        mainLayout->addWidget(browserWidget);
        mainWidget->setLayout(mainLayout);
        setCentralWidget(mainWidget);
    

    In mainwindow.h
    added necessary headers with these variables in private:

    private:
    QString browserLocation;
        QProcess *proc;
        QWidget *mainWidget;
        QVBoxLayout *mainLayout;
        QWidget *browserWidget;
    

    Both of the programs run and open firefox as seperate window. And our application doesn't show up. On both way , application doesn't die until we force it to with either from task manager or by rerunning program.

    I couldn't find anything working

    I came to know that Qtwebkit isn't that much supported by big services and I have been using MINGW :
    https://forum.qt.io/topic/132551/using-qwebkit-for-windows-with-mingw

    Let's make QT free or It will go forever

    TRUE AND FALSE <3

    Christian EhrlicherC 1 Reply Last reply
    0
    • Thank YouT Thank You

      How can I embed application like a widget in application that I created.
      I searched about this and found couple of implementation. I don't know anything about this and never read about this. But I want to make something working browser.

      This one is first answer that I found about this topic

      mainwindow.cpp

        QString prog = "C:/Program Files/Mozilla Firefox/firefox.exe";
          QStringList arg;
          arg << "google.com";
          QString workDir = "C:/Program Files/Mozilla Firefox/";
          program->startDetached(prog, arg, workDir, 0);
          WId hWnd = 0;
          while (hWnd == 0)
          {
          hWnd = (WId) FindWindowW(NULL, L"C:/Program Files/Mozilla Firefox/firefox.exe");
          }
          window = QWindow::fromWinId(hWnd);
          container = QWidget::createWindowContainer(window, ui->mdiArea);
          QMdiSubWindow *subWindow = new QMdiSubWindow();
          subWindow->setWidget(container);
          subWindow->setAttribute(Qt::WA_DeleteOnClose);
          subWindow->setWindowTitle("Program 1");
          ui->mdiArea->addSubWindow(subWindow);
          container->show();
      

      In mainwindow.h
      Added necessary headers and these variables in private

      private:
      WId id;
          QProcess *program;
          QWindow *window;
          QWidget *container;
      

      second answer

      mainwindow.cpp

       browserLocation = "C:/Program Files/Mozilla Firefox/firefox.exe";
          mainWidget = new QWidget(this);
          browserWidget = new QWidget(mainWidget);
          mainLayout = new QVBoxLayout(mainWidget);
          QLabel *label = new QLabel(mainWidget);
          label->setText("Is label showing up?");
          proc = new QProcess(this);
          proc->setProgram(browserLocation);
          proc->start();
          qDebug()<<"Started with pid "<<proc->pid();
      
      
          WId id = this->winId();
          QWindow *window = QWindow::fromWinId(id);
          browserWidget = QWidget::createWindowContainer(window,mainWidget);
      
      
      
          mainLayout->addWidget(label);
          mainLayout->addWidget(browserWidget);
          mainWidget->setLayout(mainLayout);
          setCentralWidget(mainWidget);
      

      In mainwindow.h
      added necessary headers with these variables in private:

      private:
      QString browserLocation;
          QProcess *proc;
          QWidget *mainWidget;
          QVBoxLayout *mainLayout;
          QWidget *browserWidget;
      

      Both of the programs run and open firefox as seperate window. And our application doesn't show up. On both way , application doesn't die until we force it to with either from task manager or by rerunning program.

      I couldn't find anything working

      I came to know that Qtwebkit isn't that much supported by big services and I have been using MINGW :
      https://forum.qt.io/topic/132551/using-qwebkit-for-windows-with-mingw

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Thank-You said in Opening external application and embed it without opening application out of application:

      I came to know that Qtwebkit isn't that much supported by big services:

      Use MSVC and Qt WebEngine

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      Thank YouT 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @Thank-You said in Opening external application and embed it without opening application out of application:

        I came to know that Qtwebkit isn't that much supported by big services:

        Use MSVC and Qt WebEngine

        Thank YouT Offline
        Thank YouT Offline
        Thank You
        wrote on last edited by Thank You
        #3

        @Christian-Ehrlicher
        Sorry I forgot to mention for MINGW. I will update question.
        But I am not actually sure that we can embed another application inside widget without opening it as application but it is only my thought 😂😂. Can we do it????.

        Let's make QT free or It will go forever

        TRUE AND FALSE <3

        JonBJ 1 Reply Last reply
        0
        • Thank YouT Thank You

          @Christian-Ehrlicher
          Sorry I forgot to mention for MINGW. I will update question.
          But I am not actually sure that we can embed another application inside widget without opening it as application but it is only my thought 😂😂. Can we do it????.

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

          @Thank-You
          @Christian-Ehrlicher is suggesting that a much more Qt solution is not to try to run some external Firefox browser program but rather to use Qt WebEngine which is a Chromium engine you can use as a widget in your application. It's an awful neater. However, it is true that under Windows it means you would need to use MSVC toolchain instead of MinGW.

          Thank YouT 1 Reply Last reply
          0
          • JonBJ JonB

            @Thank-You
            @Christian-Ehrlicher is suggesting that a much more Qt solution is not to try to run some external Firefox browser program but rather to use Qt WebEngine which is a Chromium engine you can use as a widget in your application. It's an awful neater. However, it is true that under Windows it means you would need to use MSVC toolchain instead of MinGW.

            Thank YouT Offline
            Thank YouT Offline
            Thank You
            wrote on last edited by
            #5

            @JonB Yes that would be good choice. I couldn't use it because some dependencies are compiled with mingw only and can only be used with them.

            Can we do it????.

            ?

            Let's make QT free or It will go forever

            TRUE AND FALSE <3

            JonBJ 1 Reply Last reply
            0
            • Thank YouT Thank You

              @JonB Yes that would be good choice. I couldn't use it because some dependencies are compiled with mingw only and can only be used with them.

              Can we do it????.

              ?

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

              @Thank-You No, you cannot use Qt WebEngine with MinGW.

              Thank YouT 1 Reply Last reply
              0
              • JonBJ JonB

                @Thank-You No, you cannot use Qt WebEngine with MinGW.

                Thank YouT Offline
                Thank YouT Offline
                Thank You
                wrote on last edited by
                #7

                @JonB
                I guess you misunderstood my question
                I mean can we embed other application in QT inside widget without showing it up in another window

                Let's make QT free or It will go forever

                TRUE AND FALSE <3

                JonBJ 1 Reply Last reply
                0
                • Thank YouT Thank You

                  @JonB
                  I guess you misunderstood my question
                  I mean can we embed other application in QT inside widget without showing it up in another window

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

                  @Thank-You
                  Probably depends on the application, don't know whether there are issues with FireFox, and I don't use Windows.

                  Since you appear to say you got one or other of your code examples from somewhere, why don't you reference where that was? If that was an example of embedding, surely that code would have been tested as working, I imagine.

                  A post from 2009, https://www.qtcentre.org/threads/23290-Embedded-browser-in-QT, answers

                  Is it possible to create a QWindow (or something like it) and embed a browser in this window?

                  The browser could be chosen by the user, IE, Firefox, Chrome...

                  with

                  The answer is "it depends but in general no".

                  I don't know if that still applies....

                  Thank YouT 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @Thank-You
                    Probably depends on the application, don't know whether there are issues with FireFox, and I don't use Windows.

                    Since you appear to say you got one or other of your code examples from somewhere, why don't you reference where that was? If that was an example of embedding, surely that code would have been tested as working, I imagine.

                    A post from 2009, https://www.qtcentre.org/threads/23290-Embedded-browser-in-QT, answers

                    Is it possible to create a QWindow (or something like it) and embed a browser in this window?

                    The browser could be chosen by the user, IE, Firefox, Chrome...

                    with

                    The answer is "it depends but in general no".

                    I don't know if that still applies....

                    Thank YouT Offline
                    Thank YouT Offline
                    Thank You
                    wrote on last edited by Thank You
                    #9

                    @JonB
                    It's limereport
                    https://limereport.ru/en/index.php

                    Almost a year ago I built it with mingw and stuck with it.
                    Thanks for your suggestion.

                    whether there are issues with FireFox

                    No I don't mean firefox specific. Any browser.

                    Although this is out of context but,
                    If you have used edge , then each tab is considered as separate window and using ALT + TAB it shows a lots of windows opened. If I got this solution I could use it there too and make it as unified so it would be easier with it too.

                    Let's make QT free or It will go forever

                    TRUE AND FALSE <3

                    JonBJ 1 Reply Last reply
                    0
                    • Thank YouT Thank You

                      @JonB
                      It's limereport
                      https://limereport.ru/en/index.php

                      Almost a year ago I built it with mingw and stuck with it.
                      Thanks for your suggestion.

                      whether there are issues with FireFox

                      No I don't mean firefox specific. Any browser.

                      Although this is out of context but,
                      If you have used edge , then each tab is considered as separate window and using ALT + TAB it shows a lots of windows opened. If I got this solution I could use it there too and make it as unified so it would be easier with it too.

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

                      @Thank-You
                      I updated my previous post with some (potentially bad) news.

                      I don't see anything in your "LimeReport" which has anything to do with embedding an external application into a Qt UI/widget, so i don't know what connection to your application is. Since it appears that you have its source code, why aren't you integrating it into your code (it says "Pure Qt4/Qt5 compatible code") rather than something about trying to run Firefox?

                      I would start out Googling for qt embed external application to assess what might be possible.

                      Thank YouT 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Thank-You
                        I updated my previous post with some (potentially bad) news.

                        I don't see anything in your "LimeReport" which has anything to do with embedding an external application into a Qt UI/widget, so i don't know what connection to your application is. Since it appears that you have its source code, why aren't you integrating it into your code (it says "Pure Qt4/Qt5 compatible code") rather than something about trying to run Firefox?

                        I would start out Googling for qt embed external application to assess what might be possible.

                        Thank YouT Offline
                        Thank YouT Offline
                        Thank You
                        wrote on last edited by
                        #11

                        @JonB
                        I mean that library is compiled with mingw 32bit and used in my application. So I linked it.
                        It doesn't have any connection with embedding.
                        As a whole main purpose is to make application run browser without opening real browser window.

                        Let's make QT free or It will go forever

                        TRUE AND FALSE <3

                        JonBJ 1 Reply Last reply
                        0
                        • Thank YouT Thank You

                          @JonB
                          I mean that library is compiled with mingw 32bit and used in my application. So I linked it.
                          It doesn't have any connection with embedding.
                          As a whole main purpose is to make application run browser without opening real browser window.

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

                          @Thank-You said in Opening external application and embed it without opening application out of application:

                          It doesn't have any connection with embedding.

                          Then I don't know what relevance it has to your question.

                          As a whole main purpose is to make application run browser without opening real browser window.

                          I quoted a potential answer of "No, not for Firefox", but suggested what you should Google for to investigate embedding external applications into Qt. (There are further specific hits for qt embed firefox.) Find one of those, see if it works, see if it can applied to your situation or not.

                          Thank YouT 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @Thank-You said in Opening external application and embed it without opening application out of application:

                            It doesn't have any connection with embedding.

                            Then I don't know what relevance it has to your question.

                            As a whole main purpose is to make application run browser without opening real browser window.

                            I quoted a potential answer of "No, not for Firefox", but suggested what you should Google for to investigate embedding external applications into Qt. (There are further specific hits for qt embed firefox.) Find one of those, see if it works, see if it can applied to your situation or not.

                            Thank YouT Offline
                            Thank YouT Offline
                            Thank You
                            wrote on last edited by
                            #13

                            @JonB
                            I have seen many of posts about this topic.
                            https://stackoverflow.com/questions/33699258/qt-5-5-embed-external-application-into-qwidget
                            All of these go out of my head. I haven't learned about these topic before.

                            I will try installing msvc and will try to work with it.
                            HOPING for the best

                            Let's make QT free or It will go forever

                            TRUE AND FALSE <3

                            JonBJ 1 Reply Last reply
                            0
                            • Thank YouT Thank You

                              @JonB
                              I have seen many of posts about this topic.
                              https://stackoverflow.com/questions/33699258/qt-5-5-embed-external-application-into-qwidget
                              All of these go out of my head. I haven't learned about these topic before.

                              I will try installing msvc and will try to work with it.
                              HOPING for the best

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

                              @Thank-You
                              You already have

                                  window = QWindow::fromWinId(hWnd);
                                  container = QWidget::createWindowContainer(window, ui->mdiArea);
                              

                              The solution at that stackoverflow link is merely to add

                              window->setFlags(window->flags() | Qt::FramelessWindowHint);
                              

                              I have no idea whether that is relevant to your situation, just saying that is all they are adding.

                              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