Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. RTF formatting in clipboard on Android
Forum Updated to NodeBB v4.3 + New Features

RTF formatting in clipboard on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 1 Posters 318 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.
  • R Offline
    R Offline
    RogueWarrior
    wrote on last edited by
    #1

    I've got some code that generates both RTF formatting (bold, underline, italics) and plain text in a pair of QStrings. I then create a QMimeData and set the clipboard to it.

    QClipboard *m_clipboard;
    
    m_MimeData = new QMimeData;
    m_MimeData->setText(tLogOutputPlain);
    m_MimeData->setHtml(tLogOutputHTML);
    
    qDebug() << "MIME set";
    
    m_clipboard->clear();
    
    qDebug() << "Clipboard cleared";
    
    m_clipboard->setMimeData(m_MimeData);
    

    On iOS, I'm able to paste the formatted text into whatever app I want and it works just fine. But on Android, the formatting gets lost. I've tried a bunch of different text editing apps including Office 365 Word which does specifically give you the option to retain formatting. This is on Qt 6.5.

    R 1 Reply Last reply
    0
    • R RogueWarrior

      I've got some code that generates both RTF formatting (bold, underline, italics) and plain text in a pair of QStrings. I then create a QMimeData and set the clipboard to it.

      QClipboard *m_clipboard;
      
      m_MimeData = new QMimeData;
      m_MimeData->setText(tLogOutputPlain);
      m_MimeData->setHtml(tLogOutputHTML);
      
      qDebug() << "MIME set";
      
      m_clipboard->clear();
      
      qDebug() << "Clipboard cleared";
      
      m_clipboard->setMimeData(m_MimeData);
      

      On iOS, I'm able to paste the formatted text into whatever app I want and it works just fine. But on Android, the formatting gets lost. I've tried a bunch of different text editing apps including Office 365 Word which does specifically give you the option to retain formatting. This is on Qt 6.5.

      R Offline
      R Offline
      RogueWarrior
      wrote on last edited by
      #2

      I decided to try not setting the plain text part of the QMimeData to see what would happen. Android doesn't think that there's anything at all in the clipboard.

      So, it's either a Qt bug or an Android bug or possibly there's some buried setting in Android that prevents you from using HTML in the clipboard.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RogueWarrior
        wrote on last edited by
        #3

        Okay, so delving into the Qt bug site, it appears that fancy clipboard support is currently in development for Android. Apparently, Android 12 and later has new functionality for this that isn't supported in Qt 6.5.

        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