Results 1 to 2 of 2

Thread: The access between WebView and HTML javascript

  1. #1
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    1

    Question The access between WebView and HTML javascript

    Hi,

    I have a question about WebView element.

    I create a HTML file named "hfile.htm", and I use a WebView with the url property is "hfile.htm".

    Now my main.qml is like:

    Qt Code:
    1. import QtQuick 1.0
    2. import QtWebKit 1.0
    3.  
    4. Rectangle {
    5. width: 600
    6. height: 400
    7. WebView { id: webMap
    8. anchors.fill: parent
    9. url: "hfile.htm"
    10. }
    11. Rectangle { id: rec1
    12. width: 100
    13. height: 100
    14. color: "red"
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    Can I change the color property of Rectangle rec1 from javascript in hfile.htm??
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: The access between WebView and HTML javascript

    You probably can but this probably requires a lot of work. You'd need to expose some objects to the page handled by WebView and then have appropriate scripts on the page manipulate those objects. You'd need to use the javaScriptWindowObjects attribute from WebView.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    wilson (18th October 2011)

Similar Threads

  1. QML webview and javascript/flash on pages
    By 0biwan in forum Qt Quick
    Replies: 0
    Last Post: 5th April 2011, 16:51
  2. Qml plugin in html inside WebView problem
    By xeento in forum Qt Quick
    Replies: 1
    Last Post: 29th January 2011, 13:27
  3. Replies: 2
    Last Post: 14th January 2011, 15:09
  4. getting javaScript from html
    By ashvindh in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2010, 12:57
  5. QtWebKit access HTML manipulated by javascript
    By rbp in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2009, 02:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.