Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to ingore specific image copy in QTextBrowser?
Forum Update on Monday, May 27th 2025

How to ingore specific image copy in QTextBrowser?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtextbrowserqtextedit
4 Posts 3 Posters 1.1k 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.
  • D Offline
    D Offline
    dscyw
    wrote on last edited by dscyw
    #1

    I have a ChatView widget based on QTextBrowser, where I put two image anchors to achieve click event. I want copy and paste action to ignore these two items. How can I achieve it?

    target items:
    0_1528338946837_8579bafd-a1a1-4c31-b205-2cb745db57f6-image.png

    select and copy:
    0_1528339054647_7dc24af3-0c3d-483f-851d-7936de3d1d3d-image.png

    paste to a widget based on QTextEdit :
    0_1528339079541_d0cfa37e-746a-4ba9-86d6-1dc1f98b4e47-image.png

    what I want to achieve without any extra editor action:
    0_1528339539593_80eec492-c10a-4f29-8413-1394ee670c4d-image.png

    raven-worxR 1 Reply Last reply
    0
    • KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by KillerSmath
      #2

      Maybe you can reimplement the Clipboard of aplication to ignore these imagens (removing them of plain text).
      But also, you can reimplement the paste action of QTextBrowser class and remove these image of plaintext.

      -> Read More:
      QTextBrowser Members
      Paste Action Documentation
      insert From MineData Documentation

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      0
      • D dscyw

        I have a ChatView widget based on QTextBrowser, where I put two image anchors to achieve click event. I want copy and paste action to ignore these two items. How can I achieve it?

        target items:
        0_1528338946837_8579bafd-a1a1-4c31-b205-2cb745db57f6-image.png

        select and copy:
        0_1528339054647_7dc24af3-0c3d-483f-851d-7936de3d1d3d-image.png

        paste to a widget based on QTextEdit :
        0_1528339079541_d0cfa37e-746a-4ba9-86d6-1dc1f98b4e47-image.png

        what I want to achieve without any extra editor action:
        0_1528339539593_80eec492-c10a-4f29-8413-1394ee670c4d-image.png

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

        @dscyw
        reimplement createMimeDataFromSelection()
        Either you recreate the whole mime-data yourself or you call the base-class implementation and remove the <img> elements from the text/html data.

        Actually you can also completely create your own mime-type and store anything you like in there. Then reimplement insertFromMimeData() and handle your custom mime-type.

        --- 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
        2
        • D Offline
          D Offline
          dscyw
          wrote on last edited by
          #4

          @KillerSmath @raven-worx Thanks. I will try it and post the result later. I think it's a non-trivial task.

          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