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. How to kill page when it's window is closed?
Servers for Qt installer are currently down

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

Scheduled Pinned Locked Moved Solved QtWebEngine
qwebengineqtwebengineqwebenginepage
3 Posts 2 Posters 1.8k 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.
  • D Offline
    D Offline
    Daniil Kolesnichenko
    wrote on last edited by Daniil Kolesnichenko
    #1

    I handle target="_blank" links this way:

    QWebEngineView *BrowserView::createWindow(QWebEnginePage::WebWindowType)
    {
        MainWindow *win = new MainWindow();
        win->show();
        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
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      Hi Daniil Kolesnichenko,

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

      setAttribute(Qt::WA_DeleteOnClose);
      

      to your MainWindow.

      D 1 Reply Last reply
      1
      • M mpergand

        Hi Daniil Kolesnichenko,

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

        setAttribute(Qt::WA_DeleteOnClose);
        

        to your MainWindow.

        D Offline
        D Offline
        Daniil Kolesnichenko
        wrote on last edited by
        #3

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

        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