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. HTML5 Canvas & Same-Origin
Forum Update on Monday, May 27th 2025

HTML5 Canvas & Same-Origin

Scheduled Pinned Locked Moved Qt WebKit
1 Posts 1 Posters 705 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.
  • Z Offline
    Z Offline
    zeveck
    wrote on 31 Jul 2014, 16:47 last edited by
    #1

    I am loading the page into QWebView like so,

    @QWebView::setHtml(content, QUrl("file://"));@

    The content includes something like,

    @<img src="file:///F:\foo.png">@

    I then try to do this in JS:

    @var canvas = document.querySelector("canvas");
    var cxt = canvas.getContext("2d");
    var image = document.querySelector("image");
    cxt.drawImage(image, 0, 0);
    var imgData = cxt.getImageData(1, 1, 1, 1);@

    This doesn't work, apparently due to a SameOrigin error because if I just add,

    @settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);@

    then it works fine, except I don't want to do this since it's a general security concern...

    But since the page is loaded with base "file://" and the file is being loaded from "file://" ... how is this a SameOrigin conflict!?

    Can anybody explain what I'm missing?

    (I'm using Qt 4.8.4.)

    1 Reply Last reply
    0

    1/1

    31 Jul 2014, 16:47

    • Login

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