Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Google Maps not displaying in WebView, other sites work
Forum Updated to NodeBB v4.3 + New Features

Google Maps not displaying in WebView, other sites work

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 3 Posters 4.4k Views 1 Watching
  • 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.
  • Q Offline
    Q Offline
    Qu0ll
    wrote on last edited by
    #1

    I just picked up Qt and QML for the first time and the first thing I wanted to get working was just to open Google Maps in a WebView but it doesn't work.

    Here's the QML:

    @import QtQuick 2.0
    import QtWebKit 3.0

    Rectangle {
    width: 1024
    height: 960
    WebView {
    width: 1024
    height: 960
    anchors.centerIn: parent
    url: "http://maps.google.com"
    }
    }
    @

    The window opens but the contents of the WebView are completely blank. If I try other websites then the correct web page is displayed.

    What's wrong with this code? I am not behind any proxy or firewall. I suspect it is something to do with HTTPS given that some maps APIs use HTTPS but I don't see why HTTP would work but not HTTPS.

    I am using Qt 5.1 on Windows 7 64-bit.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qu0ll
      wrote on last edited by
      #2

      Anyone?

      This is my first look at Qt and it seems even the most basic thing does not work! Why?

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        You are probably correct that the issue is due to HTTPS. If you modify your code to probe for errors...
        @
        import QtQuick 2.0
        import QtWebKit 3.0

        WebView {
        width: 1024
        height:960
        url: "http://maps.google.com"

        Component.onCompleted: {
            onLoadingChanged.connect(report)
        }
        
        function report(loadRequest) {
            console.log(loadRequest.errorString)
        }
        

        }
        @
        ...you will probably see an error message like "Unable to init SSL Context".

        Qt cannot ship SSL libraries for legal reasons. From http://qt-project.org/doc/qt-5.1/qtnetwork/ssl.html :
        [quote]Due to import and export restrictions in some parts of the world, we are unable to supply the OpenSSL Toolkit with Qt packages. Developers wishing to use SSL communication in their deployed applications should either ensure that their users have the appropriate libraries installed, or they should consult a suitably qualified legal professional to ensure that applications using code from the OpenSSL project are correctly certified for import and export in relevant regions of the world.[/quote]
        You'll need to install OpenSSL separately, then tell your project to link against the the library: http://qt-project.org/forums/viewthread/25799

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qu0ll
          wrote on last edited by
          #4

          OK, I'll check that out, thanks.

          On a related note, I see that there is a class that can define the proxy settings that can be applied to the application as a whole but it does not seem to have any options for HTTPS (it has HTTP only).

          How would I configure the proxy settings for HTTPS for the application as a whole?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MaximAlien
            wrote on last edited by
            #5

            Hi,

            I had the same issue with GoogleMaps but using QNetworkRequest. If you request "page":http://maps.google.com Google will redirect you "here":https://maps.google.com I managed to fix this issue using RawHeaders from QNetworkReply.

            Maybe this "thread":http://qt-project.org/forums/viewthread/29760/ will help you.

            Cheers,
            Max.

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              You're welcome, Qu0ll.

              [quote]On a related note, I see that there is a class that can define the proxy settings that can be applied to the application as a whole but it does not seem to have any options for HTTPS (it has HTTP only).

              How would I configure the proxy settings for HTTPS for the application as a whole?[/quote]That's outside my field, sorry -- I don't work with HTTPS much myself. From what I remember though, some of the API is HTTP only.

              You could get better answers about HTTPS configuration from others if you start a new thread. Or even better, ask at the "#qt IRC channel":http://qt-project.org/wiki/OnlineCommunities or the "Interest mailing list":http://lists.qt-project.org/mailman/listinfo/interest -- Qt's engineers are active at those two places.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                Qu0ll
                wrote on last edited by
                #7

                Has anyone actually managed to get Google Maps to display in a WebView? If so, could you please describe what needs to be done to get it to work? My attempts are failing miserably :-(

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  Qu0ll
                  wrote on last edited by
                  #8

                  I have it working now. The problem was with the way I installed OpenSSL as discussed in this "thread":http://qt-project.org/forums/viewthread/25799/

                  Thanks to everyone who contributed suggestions!

                  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