How can I disable selection property on Qwebview
-
I want to do it, I need some help if some body can guide me or give me some hint, I how I can do this in webkit or Qt code.
-
You could look at how -webkit-user-select is implemented. Disabling selection is probably using the same path.
-
There is a thread on this subject on the mailing list: "https://lists.webkit.org/pipermail/webkit-qt/2010-October/000896.html":https://lists.webkit.org/pipermail/webkit-qt/2010-October/000896.html
-
I bug is already filed here at bugzilla, for this
https://bugs.webkit.org/show_bug.cgi?id=38520 -
Wow here is way you can do it
@
QApplication a(argc, argv);
QWebView *view = new QWebView;
view->load(QUrl("http://google.com"));
view->page()->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile("mycss.css"));
view->show();
return a.exec();@your css file should be like this:
body {
-webkit-user-select: none;
} -
You know what, I just tried putting the css thing in resource file and now I can see it is part of my binary so no need of css file. function setUserStyleSheetUrl() is dong the job of disabling selection.
-
This works great, after long time I got something. Thanx immii
-
your submitted code is very helpful for disable the selection on text and image.
but your code is not helpful in case while user drag the image with press button. -
bool QWebView::findText ( const QString & subString, QWebPage::FindFlags options = 0 )
To clear the selection, just pass an empty string. -
@kmsharad83 This is what I do in jQuery. You can adapt it to your needs:
$(document).ready(function(){ // Prevent anchor links and buttons and .nodrag items from being dragged $('A,BUTTON,.nodrag,IMG') .css('-moz-user-select','none') .css('-webkit-user-select','none') .bind('selectstart', function(e) { e.preventDefault(); return false; }) .bind('draggesture', function(e) { e.preventDefault(); return false; }) .bind('draggable', function(e) { e.preventDefault(); return false; }) .bind('dragstart', function(e) { e.preventDefault(); return false; }); });