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 http://summernote.org/
    my code follow:

    ui->webView->settings()->setDefaultTextEncoding("utf-8");
    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-----------------
    $inputbox.on('paste',function(event){
    var clipboardData;
    if(event.clipboardData)
    {
    clipboardData = event.clipboardData;
    }
    if(event.originalEvent.clipboardData)
    {
    clipboardData = event.originalEvent.clipboardData;
    }
    var items;
    if(clipboardData)
    {

    //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);
    	$('<img>').appendTo(document.body)
        .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).

    http://stackoverflow.com/questions/10258102/is-there-a-non-flash-way-to-set-get-the-clipboard-data-in-webkit


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.