How to kill page when it's window is closed?

  • I handle target="_blank" links this way:

    QWebEngineView *BrowserView::createWindow(QWebEnginePage::WebWindowType)
        MainWindow *win = new MainWindow();
        BrowserView *browserView = win->findChild<BrowserView *>("browserView");
        return browserView;

    So when I click a link that is supposed to be opened in new tab/window, a new MainWindow is created and the url is opened there. That's ok, but if I close that window, the page obviously isn't killed — the sound from that page continues to play. How can I close/kill the page when the window is closed?

    MainWindow declaration:

    class MainWindow : public QMainWindow
        explicit MainWindow(QWidget *parent = 0);
        Ui::MainWindow *ui;

  • Hi Daniil Kolesnichenko,

    Is the MainWindow's destructor called ?
    Maybe you need to add


    to your MainWindow.

  • @mpergand you are right, this line solved the problem. Thank you very much!

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.