Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. JQuery doesn't works when the page is loaded from resource
QtWS25 Last Chance

JQuery doesn't works when the page is loaded from resource

Scheduled Pinned Locked Moved Qt WebKit
6 Posts 2 Posters 4.3k 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.
  • M Offline
    M Offline
    marcus.fr
    wrote on 25 Aug 2012, 00:06 last edited by
    #1

    Hi

    I need to load web page and jQuery both from Qt Resources. I looked at the Fancy Browser example but it shows a case of loading page from internet and loading jQuery from resources (which btw works fine). Here is my scenario:

    @//Case 1# The page text is shown but the graphic elements based on jQuery are not shown at all
    tQWebView->load("qrc:///index.html");

    //Case 2# The page text and graphic elements are both shown
    tQWebView->load("file:///E:/index.html");@

    The file index.html is completely the same in both cases. I load jQuery in this file with this line:
    @<scr1pt language="javascript" type="text/javascript" src="qrc:///javascript/jquery.js"></scr1pt>@

    I use Qt 4.8 and I cannot find the reason why I cannot get it to work for Case 1 as well. Note that for the index.html code above I intentionally use scr1pt instead of script because the forum wont let me have it in the original form.

    Thanks for consideration!

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peppy
      wrote on 26 Aug 2012, 17:56 last edited by
      #2

      I am not sure that QWebView "knows" QRC protocol ;) :D. Try to use normal web address from jQuery CDN:
      @
      http://code.jquery.com/jquery-1.8.0.min.js
      @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        marcus.fr
        wrote on 27 Aug 2012, 11:30 last edited by
        #3

        [quote author="Peppy" date="1346003767"]I am not sure that QWebView "knows" QRC protocol ;) :D.[/quote]

        The QUrl based on QRC path works fine when I load a page in QWebKit. The page is displayed, however the jQuery based drawings are not shown. If the same html code is loaded from a local file than the page displays the drawings fine, even though the html code in the local file uses QRC path to link to jQuery js files.

        The html code (index.html) is exactly same file in both cases, and in this file the jQuery is linked using QRC path as shown below below:
        @<scr1pt language="javascript" type="text/javascript" src="qrc:///javascript/jquery.js"></scr1pt>@

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Peppy
          wrote on 27 Aug 2012, 12:02 last edited by
          #4

          Yes, QWebView using QUrl, but does it have WebKit Core ?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            marcus.fr
            wrote on 27 Aug 2012, 19:33 last edited by
            #5

            [quote author="Peppy" date="1346068934"]Yes, QWebView using QUrl, but does it have WebKit Core ? [/quote]

            I don't think QUrl is used by webkit at all. QWebView uses QUrl to get the data from the source and delivers the data in a form of html string for WebKit to process.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              marcus.fr
              wrote on 29 Aug 2012, 01:29 last edited by
              #6

              Currently I use a workaround: I save the html code to a file and then use QWebView::load to open it. However it comes with the price of speed.

              1 Reply Last reply
              0

              5/6

              27 Aug 2012, 19:33

              • Login

              • Login or register to search.
              5 out of 6
              • First post
                5/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved