Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. How to disable user-text-selection without using CSS Stylesheet?

How to disable user-text-selection without using CSS Stylesheet?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
4 Posts 2 Posters 1.5k Views
  • 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.
  • S Offline
    S Offline
    SteKo_dev
    wrote on last edited by
    #1

    I am using the QtWebengine in Version 5.9.4 based in Chromium 56.

    I've tried to find an option to disable the text selection on html pages in the source code of my QT Project, but I did not found any option to do this.

    I know the option, using CSS Stylesheets, but this is no possible solution for my project because the customers often implements this option not in their sourcecode stylesheets and don't want to change it afterwards.

    Is their any possibility to change this behavior in the QtWebEngine Framework or do I need to find a solution on the Chromium based source code?

    raven-worxR 1 Reply Last reply
    0
    • S SteKo_dev

      I am using the QtWebengine in Version 5.9.4 based in Chromium 56.

      I've tried to find an option to disable the text selection on html pages in the source code of my QT Project, but I did not found any option to do this.

      I know the option, using CSS Stylesheets, but this is no possible solution for my project because the customers often implements this option not in their sourcecode stylesheets and don't want to change it afterwards.

      Is their any possibility to change this behavior in the QtWebEngine Framework or do I need to find a solution on the Chromium based source code?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @SteKo_dev
      you can still include a default stylesheet (transparent for each user) - independently for the page loaded.
      See this example.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SteKo_dev
        wrote on last edited by
        #3

        With your help,I found a solution to do that, but in my opinion its really dirty to inject code to a customer html document.

        It works for the first moment, but I’d like to find a solution without injecting code to a customer page.

        See code below.

        WebEngineView.runJavaScript("var head = document.head;" +
                              "var node= document.createElement('style');" +
                              "var textnode = document.createTextNode('body {-webkit-user-select: none !important;}');" +
                              "node.appendChild(textnode);head.appendChild(node);"
                             ,function(){/*Empty function for callback*/})
        

        Is there any possibility to change it in the chromium based source code by default ?

        raven-worxR 1 Reply Last reply
        0
        • S SteKo_dev

          With your help,I found a solution to do that, but in my opinion its really dirty to inject code to a customer html document.

          It works for the first moment, but I’d like to find a solution without injecting code to a customer page.

          See code below.

          WebEngineView.runJavaScript("var head = document.head;" +
                                "var node= document.createElement('style');" +
                                "var textnode = document.createTextNode('body {-webkit-user-select: none !important;}');" +
                                "node.appendChild(textnode);head.appendChild(node);"
                               ,function(){/*Empty function for callback*/})
          

          Is there any possibility to change it in the chromium based source code by default ?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @SteKo_dev said in How to disable user-text-selection without using CSS Stylesheet?:

          Is there any possibility to change it in the chromium based source code by default ?

          i would say THAT is the dirty way actually. You would have to make the change for every release?!
          I don't see why the injection should be dirty in your opinion. Thats actually pretty normal in Web 2.0 to dynamically inject content into a webpage.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          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