RTF formatting in clipboard on Android
-
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.
-
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.
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.
-
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.