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. How can I disable selection property on Qwebview
Forum Updated to NodeBB v4.3 + New Features

How can I disable selection property on Qwebview

Scheduled Pinned Locked Moved Qt WebKit
15 Posts 7 Posters 16.3k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    mprakash
    wrote on last edited by
    #6

    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.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      benjamin.poulain
      wrote on last edited by
      #7

      You could look at how -webkit-user-select is implemented. Disabling selection is probably using the same path.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        benjamin.poulain
        wrote on last edited by
        #8

        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

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Immii
          wrote on last edited by
          #9

          I bug is already filed here at bugzilla, for this
          https://bugs.webkit.org/show_bug.cgi?id=38520

          1 Reply Last reply
          0
          • I Offline
            I Offline
            Immii
            wrote on last edited by
            #10

            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;
            }

            1 Reply Last reply
            0
            • I Offline
              I Offline
              Immii
              wrote on last edited by
              #11

              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.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mprakash
                wrote on last edited by
                #12

                This works great, after long time I got something. Thanx immii

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kmsharad83
                  wrote on last edited by
                  #13

                  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.

                  M 1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    gbmm
                    wrote on last edited by
                    #14

                    bool QWebView::findText ( const QString & subString, QWebPage::FindFlags options = 0 )
                    To clear the selection, just pass an empty string.

                    1 Reply Last reply
                    0
                    • K kmsharad83

                      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.

                      M Offline
                      M Offline
                      maximo
                      wrote on last edited by
                      #15

                      @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;
                          });
                      });
                      
                      1 Reply Last reply
                      0

                      • Login

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