Qt5.2 webview html5 drag&drop failed
-
i write a webpage with image drag and drop from a img tag to div…it works fine in chrome and other browser..with Qt4.8.4 webview it works fine too..but with qt5.2.0 webview it failed…i don’t kown why. does anyone can fix this problem….thanks
-
Hi and welcome to devnet,
You should check the "bug report system":http://bugreports.qt-project.org to see whether it's something known. If not you could consider opening a new bug report providing a minimal compilable example that reproduces the problem.
-
Drag and Drop DOM elements work fine in QT5.2:
@var a = document.getElementById("mainDiv");
a.ondrop = function(){
//something
};
a.ondragover = function(){
//something
};@File drop work fine in QT5.2:
@a.ondrop = function(e) {
e.stopPropagation();
e.preventDefault();// fetch FileList object
var files = e.target.files || e.dataTransfer.files;for (var i = 0, f; f = files[i]; i++) {
console.log(f);
}
}@I believe it is a fault in your Javascript, try running the following URLs in your projects:
- http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop (DOM drag and drop)
- http://blogs.sitepointstatic.com/examples/tech/filedrag/1/index.html (file drop)
If the problem persists then I think you have not enabled in your webView DROP, try this:
@WEBVIEW->setAcceptDrops(true);@If it still does not work, you might not have Javascript enabled, try this:
@QWebSettings *settings = QWebSettings::globalSettings();settings->setAttribute(QWebSettings::JavascriptEnabled, true);@
To do all these tests, enable the "Inspector":
@QWebSettings *settings = QWebSettings::globalSettings();
settings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);@
and the right-click (before any testing) open the Console.