Is it possible to open link in the default browser from QtWebView(Qml)?



  • Hello, I want to open link in the browser from QtWebView(Qml). This approach was unsuccessful for me. When I click on link I get error to console:

    [9888:9376:1203/170259.011:ERROR:frame_sink_provider_impl.cc(34)] No RenderWidgetHost exists with id 6 in process 3
    

  • Qt Champions 2017

    Can you show the code on how you are doing it ? It helps to check.



  • The qml code:

        WebView {
            id: webView
            url: homeViewUrl
    
            width: parent.width
            height: parent.height
        }
    

    The html code:

    <!DOCTYPE html>
    <html>
      <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
      </head>
      <body oncontextmenu="return false">
        <a href="https://www.google.com/"  
          onclick="window.open('https://www.google.com/', 
                             'newwindow', 
                             'width=300,height=250'); 
                  return false;"
        >Link</a>
      </body>
    </html>
    

  • Qt Champions 2017

    Which platform are you trying ? Can you try with simple example like the following ?

    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        WebView {
               id: webView
               url: "http://www.google.com"
               width: parent.width
               height: parent.height
        }
    }
    


  • Windows. But the goal is to run also on Android and iOS. Yes that example is working. The WebView loads the page. The problem is that I want to open link in the default browser and it's not working. (The Link is in the loaded .html in the WebView.)

    For example if I open this file:

    <!DOCTYPE html>
    <html>
      <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
      </head>
      <body oncontextmenu="return false">
        <a href="https://www.google.com/"  
          onclick="window.open('https://www.google.com/', 
                             'newwindow', 
                             'width=300,height=250'); 
                  return false;"
        >Link</a>
      </body>
    </html>
    

    with my browser and press the link - the other browser window opens(not tab). I want the same functionality, but using qml WebView(when I press link it should open new default browser window).


Log in to reply
 

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