Important: Please read the Qt Code of Conduct -

How to process target=_blank links in QtWebEngine?

  • I overloaded QWebEnginePage::acceptNavigationRequest method, but seems that it is not called when link's target is "_blank" (i.e. when link is supposed to be opened in new window). How can I handle such links and open them in new app instances?

  • Look at the createWindow method:

    [virtual protected] QWebEngineView *QWebEngineView::createWindow(QWebEnginePage::WebWindowType type)
    This function is called from the createWindow() method of the associated QWebEnginePage 
    each time the page wants to create a new window of the given type.
    For example, when a JavaScript request to open a document in a new window is issued.
    Note: If the createWindow() method of the associated page is reimplemented, 
    this method is not called, unless explicitly done so in the reimplementation.
    See also QWebEnginePage::createWindow().

    Note that there is a dedicated WebEngine forum HERE

  • @mpergand Thank you very much! It is exactly what I need.

    UPD: there's no "mark as a correct answer" button under your post... how can I mark question as solved?

Log in to reply