Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Close QWebEngineProcess.exe
Forum Updated to NodeBB v4.3 + New Features

Close QWebEngineProcess.exe

Scheduled Pinned Locked Moved Unsolved QtWebEngine
4 Posts 2 Posters 1.1k 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.
  • HolidayH Offline
    HolidayH Offline
    Holiday
    wrote on last edited by Holiday
    #1

    Hello, Qt community. I was faced with a problem, that after closing QDialog with web content, the QWebEngineProcess.exe process is not closing. Here is a fast example

    #include <QApplication>
    #include <QWebEngineView>
    #include <QWebEngineSettings>
    #include <QDialog>
    #include <QMainWindow>
    #include <QLayout>
    #include <QtGui>
    #include <QPushButton>
    
    class Dialog : public QDialog
    {
    public:
        Dialog() : QDialog(nullptr)
        {
            resize(512, 512);
            setAttribute(Qt::WA_DeleteOnClose);
            auto verticalLayout = new QVBoxLayout(this);
            verticalLayout->setSpacing(0);
            verticalLayout->setContentsMargins(0, 0, 0, 0);
    
            m_webView = new QWebEngineView(this);
            verticalLayout->addWidget(m_webView);
        }
    
        void openPage(const QUrl& url)
        {
            m_webView->setUrl(url);
        }
    
    private:
        QWebEngineView* m_webView;
    };
    
    
    class MainWindow : public QMainWindow
    {
    public:
        MainWindow() : QMainWindow(nullptr)
        {
            resize(512, 512);
            QPushButton* btn = new QPushButton("open web dialog", this);
            connect(btn, &QPushButton::clicked, [this] ()
                    {
                        if (m_dialog == nullptr)
                        {
                            m_dialog = new Dialog();
                            m_dialog->openPage(QUrl("https://www.qt.io"));
                            m_dialog->show();
                        }
                    });
        }
    
    private:
        QPointer<Dialog> m_dialog;
    
    };
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setOrganizationName("QtExamples");
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QApplication app(argc, argv);
    
        MainWindow window;
        window.show();
    
        return app.exec();
    }
    

    I'm expecting, that after Dialog closed, QWebEngineProcess.exe will be closed too, because I'm not using webengine anymore. P.S. During opening WebPage, I have 2 QWebEngineProcess.exe. One is disappearing, but the second one left

    Will appreciate any help/ideas!

    JonBJ 1 Reply Last reply
    0
    • HolidayH Holiday

      Hello, Qt community. I was faced with a problem, that after closing QDialog with web content, the QWebEngineProcess.exe process is not closing. Here is a fast example

      #include <QApplication>
      #include <QWebEngineView>
      #include <QWebEngineSettings>
      #include <QDialog>
      #include <QMainWindow>
      #include <QLayout>
      #include <QtGui>
      #include <QPushButton>
      
      class Dialog : public QDialog
      {
      public:
          Dialog() : QDialog(nullptr)
          {
              resize(512, 512);
              setAttribute(Qt::WA_DeleteOnClose);
              auto verticalLayout = new QVBoxLayout(this);
              verticalLayout->setSpacing(0);
              verticalLayout->setContentsMargins(0, 0, 0, 0);
      
              m_webView = new QWebEngineView(this);
              verticalLayout->addWidget(m_webView);
          }
      
          void openPage(const QUrl& url)
          {
              m_webView->setUrl(url);
          }
      
      private:
          QWebEngineView* m_webView;
      };
      
      
      class MainWindow : public QMainWindow
      {
      public:
          MainWindow() : QMainWindow(nullptr)
          {
              resize(512, 512);
              QPushButton* btn = new QPushButton("open web dialog", this);
              connect(btn, &QPushButton::clicked, [this] ()
                      {
                          if (m_dialog == nullptr)
                          {
                              m_dialog = new Dialog();
                              m_dialog->openPage(QUrl("https://www.qt.io"));
                              m_dialog->show();
                          }
                      });
          }
      
      private:
          QPointer<Dialog> m_dialog;
      
      };
      
      int main(int argc, char *argv[])
      {
          QCoreApplication::setOrganizationName("QtExamples");
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QApplication app(argc, argv);
      
          MainWindow window;
          window.show();
      
          return app.exec();
      }
      

      I'm expecting, that after Dialog closed, QWebEngineProcess.exe will be closed too, because I'm not using webengine anymore. P.S. During opening WebPage, I have 2 QWebEngineProcess.exe. One is disappearing, but the second one left

      Will appreciate any help/ideas!

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

      @Holiday
      You're not supposed to worry about this. Qt WebEngine spawns various instances of that external WebEngine process which come and go to do its work, as you have seen. It seems to leave at least one around once it has spawned it (efficiency, re-use, whatever), and that closes I think when your application exits. I don't know of an interface available to force it to close. You would have to do something like an OS look-up of running processes and OS kill it, which is at least "not documented".

      1 Reply Last reply
      0
      • HolidayH Offline
        HolidayH Offline
        Holiday
        wrote on last edited by
        #3

        I have certain reasons to close this process. I tried to kill this process, but it recreates another instance before terminating. So I always see one.

        JonBJ 1 Reply Last reply
        0
        • HolidayH Holiday

          I have certain reasons to close this process. I tried to kill this process, but it recreates another instance before terminating. So I always see one.

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

          @Holiday
          Doesn't surprise me! You could look around the sources to understand what is going on.

          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