It seems, that QMimeData on Mac OSX (Qt 4.2.1) is a little bit confused when the clipboard holds multiple formats. When select & copy a whole webpage in different browsers (I tried Safari, Camino, Firefox and Opera), then it shows me, that there are multiple clipboard-formats of type "text/plain".

Here is the relevant part of my code:

Qt Code:
  1. #include <iostream>
  2. #include <Qt/qtextedit.h>
  3. #include <Qt/qtextdocumentfragment.h>
  4. #include <Qt/qmimedata.h>
  5.  
  6. class MyTextEdit : public QTextEdit
  7. {
  8. public:
  9. void insertFromMimeData(const QMimeData *source);
  10. };
  11.  
  12. void MyTextEdit::insertFromMimeData(const QMimeData *source)
  13. {
  14. if (!source)
  15. return;
  16.  
  17. QStringList formats = source->formats();
  18. for(int i = 0; i < formats.size(); ++ i) {
  19. std::cerr << "Mime Format: " << formats.at(i).toStdString() << std::endl;
  20. }
  21. std::cerr << "source->hasHtml(): " << source->hasHtml() << std::endl;
  22. // ... insert here the real body
  23. }
To copy to clipboard, switch view to plain text mode 

Now I open some webpage in the browser, on the keyboard I type <Apple>A and <Apple>C (which corresponds to Ctrl-A / Ctrl-C on Windows/Linux) and then <Apple>V in my widget.

Depending on the browser I see:
Browser Camino:
Mime Format: text/plain
Mime Format: text/plain
source->hasHtml(): 0

Firefox:
Mime Format: text/plain
Mime Format: text/plain
source->hasHtml(): 0

Safari: (note, that I get three times text/html)
Mime Format: text/plain
Mime Format: text/plain
Mime Format: text/plain
source->hasHtml(): 0

Opera:
Mime Format: text/plain
Mime Format: text/plain
source->hasHtml(): 0


On Linux I get a lot of different formats, for example Firefox shows this output:
Mime Format: TIMESTAMP
Mime Format: TARGETS
Mime Format: MULTIPLE
Mime Format: text/html
Mime Format: text/_moz_htmlcontext
Mime Format: text/_moz_htmlinfo
Mime Format: UTF8_STRING
Mime Format: text/plain
Mime Format: COMPOUND_TEXT
Mime Format: TEXT
Mime Format: STRING
Mime Format: text/x-moz-url-priv
source->hasHtml(): 1

And with Opear I see this
Mime Format: text/plain;charset=UTF-8
Mime Format: text/plain;charset=ISO-10646-UCS-2
Mime Format: text/plain
Mime Format: text/plain;charset=iso8859-1
Mime Format: UTF8_STRING
Mime Format: TEXT
Mime Format: COMPOUND_TEXT
Mime Format: STRING
Mime Format: TARGETS
Mime Format: MULTIPLE
Mime Format: TIMESTAMP
source->hasHtml(): 0

Similar different mime types can be seen with other browsers on Linux and Windows too.

No I am wondering, why all those four Browsers on OSX add multiple times a mime type of text/plain into the buffer whereas the same browsers use different types on Linux. I do not care for the number of different formats, I am just wondering why I get multiple text/plain.

Is this a known bug or is there a need for some special handling of the class QMimeData on OSX?

Thanks