How to ingore specific image copy in QTextBrowser?

  • 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:

    select and copy:

    paste to a widget based on QTextEdit :

    what I want to achieve without any extra editor action:

  • 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

  • Moderators

    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.

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.