Home > OS >  Get link of the page that createWindow() opens
Get link of the page that createWindow() opens

Time:07-04

Im trying to make a tab system

This code gives me the link of the page that i am currently on, i would like to get the link of the page i clicked on. In this code if i change return nullptr; to return this;, the clicked page will open in the same tab.

QWebEngineView* createWindow(QWebEnginePage::WebWindowType type)
{
    if(type == QWebEnginePage::WebBrowserTab)
    {
        emit new_url(this->url());
        return nullptr;
    }
    return nullptr;
}

What does return mean in the QWebEngineView::createWindow() function?

How could i get the link i clicked on?

CodePudding user response:

This little change worked for me:

QWebEngineView* createWindow(QWebEnginePage::WebWindowType type)
{
    if(type == QWebEnginePage::WebBrowserTab)
    {
       MyWebView *webView = new MyWebView();
        emit new_tab(webView);
        return webView;
    }
    return nullptr;
}

this code creates a new MyWebView object and send it to another function i implemented to create tabs and finally, return webView opens the new link in the webView object

  •  Tags:  
  • c qt
  • Related