How to ensure that an HTML-table in QTextEdit is copied as a table when pasting into for instance Excel?
-
wrote on 23 May 2016, 12:57 last edited by
We use a QTextEdit instance to display some results of calculations in tabular form. We would like to be able to copy such tables and paste them into for instance Excel.
In our current (naive) implementation each value from the HTML table, becomes a separate row in Excel. How can we do better?
-
We use a QTextEdit instance to display some results of calculations in tabular form. We would like to be able to copy such tables and paste them into for instance Excel.
In our current (naive) implementation each value from the HTML table, becomes a separate row in Excel. How can we do better?
@Jakob
How do you create the drop data?
When you simply create text/plain i guess it will become a single row/cell.
Probably making sure, that you create text/html mimedata excel will paste them differently.
But i am not sure. -
@Jakob
How do you create the drop data?
When you simply create text/plain i guess it will become a single row/cell.
Probably making sure, that you create text/html mimedata excel will paste them differently.
But i am not sure.wrote on 23 May 2016, 13:35 last edited by@raven-worx Thanx for reading and taking some time to help me out.
Here with 'copying' I simply mean selecting the relevant text in the QTextEdit and hitting Ctrl+C.
-
@raven-worx Thanx for reading and taking some time to help me out.
Here with 'copying' I simply mean selecting the relevant text in the QTextEdit and hitting Ctrl+C.
@Jakob
what happens if you do this?QMimeData* MyTextEdit::createMimeDataFromSelection() { QMimeData* origData = QTextEdit::createMimeDataFromSelection(); QMimeData* data = new QMimeData; data->setData( "text/html", origData->data("Text/html") ) delete origData; retrun Data; }
-
@Jakob
what happens if you do this?QMimeData* MyTextEdit::createMimeDataFromSelection() { QMimeData* origData = QTextEdit::createMimeDataFromSelection(); QMimeData* data = new QMimeData; data->setData( "text/html", origData->data("Text/html") ) delete origData; retrun Data; }
wrote on 24 May 2016, 08:04 last edited by@raven-worx Thanx for the suggestion. I think we can go a long way with this, except that we are on Windows and it seems we need some Windows-specific MIME-conversions. We'll try to tinker a bit with that.
1/5