Important: Please read the Qt Code of Conduct -

QWebView<Qt5.5> paste image in clipboard does not work

  • i add a WYSIWYG HTML Editor ,but paste not work,the same work in chrome 、firefox,etc..

    you can visit this test
    my code follow:

    ui->webView->settings()->globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    ui->webView->settings()->globalSettings()->setAttribute(QWebSettings::JavaEnabled, true);
    ui->webView->settings()->globalSettings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
    ui->webView->settings()->globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);

    ---------------html is-----------------
    var clipboardData;
    clipboardData = event.clipboardData;
    clipboardData = event.originalEvent.clipboardData;
    var items;

    //here error,clipboardData no property named items
    items = clipboardData.items;
    var tt = items[0].getAsFile();

    debug('file is ok:');
    readFileAsDataURL(tt).then(function (sDataURL) {
    	debug('read is ok:'+sDataURL);
        .attr('src', sDataURL);
      }).fail(function () {
    	  debug('read is failed:');


  • You can get the clipboard data in WebKit, but only during a paste event, for security reasons (random websites being able to copy from your system clipboard at any time would be bad).

Log in to reply