Results 1 to 9 of 9

Thread: Is there a known problem with QMimeData on Mac OS X?

  1. #1
    Join Date
    Apr 2006
    Posts
    31
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Is there a known problem with QMimeData on Mac OS X?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,351
    Thanks
    3
    Thanked 5,005 Times in 4,784 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    Quote Originally Posted by Wurgl View Post
    Is this a known bug or is there a need for some special handling of the class QMimeData on OSX?
    I suggest you check the tasktracker.

  3. #3
    Join Date
    Apr 2006
    Posts
    31
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    Quote Originally Posted by wysota View Post
    I suggest you check the tasktracker.
    When searching for QMimeData I did not find anything which smells similar

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,351
    Thanks
    3
    Thanked 5,005 Times in 4,784 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    Try upgrading your Qt installation (4.3.4 is the latest stable release).

  5. #5
    Join Date
    Apr 2006
    Posts
    31
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    Quote Originally Posted by wysota View Post
    Try upgrading your Qt installation (4.3.4 is the latest stable release).
    The duples are gone. Now I see just one plain/text entry in the clipboard. This does not really solve my problem, since I would like to get the html-source similar to the other two platforms.

    I do not know how the textedit application (distributed with Mac OSX) handles it, but this programm is able to receive the html-code from at least safari with the same sequence of <Apple>A/<Apple>C and <Apple>V in the textedit window. It looks a little bit like garbage, but it contains links (and this is what I would like to get).

  6. #6
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    On my mac i use.....

    qmake -v
    QMake version 2.01a
    Using Qt version 4.4.0-snapshot-20070608 in /usr/local/Trolltech/Qt-4.4.0-snapshot-20070608/lib

    and its run OK

    try to build
    http://code.google.com/p/qxhtml-edit/

    only append text plain ...
    http://qxhtml-edit.googlecode.com/sv...c/qvimedit.cpp

    Qt Code:
    1. void QVimedit::insertFromMimeData ( const QMimeData * source )
    2. {
    3.  
    4. //////////qDebug() << "### insertFromMimeData 2 ";
    5.  
    6. if ( source->hasImage() ) {
    7. numerobase++;
    8. const QString nuovaim = QString("%2/image_%1.png").arg(numerobase).arg(QDir::homePath());
    9. QImage images = qvariant_cast<QImage>(source->imageData());
    10. bool salvato = images.save(nuovaim,"PNG",100);
    11. //////////////////qDebug() << "### salvato 1/0 " << salvato;
    12. emit TakeImage(nuovaim); /* and remove nuovaim */
    13. return;
    14.  
    15. }
    16.  
    17. ////////////////QTextEdit::insertFromMimeData(source);
    18. if ( source->formats().contains("text/html") ) {
    19. ////////qDebug() << "### incomming paste text/html ";
    20. const QString tidicaches = QString("%2/.qtidy/").arg(QDir::homePath());
    21. QString draghtml = source->html();
    22. /* fwriteutf8(QString fullFileName,QString xml) */
    23. QTidy *tidy = new QTidy(); /* QTidy *tidy; */
    24. tidy->Init(tidicaches); /* tidy cache remove on last event */
    25. const QString xhtmlnew = tidy->TidyExternalHtml(draghtml);
    26. ///////fwriteutf8("copy_in.html",xhtmlnew);
    27. QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(xhtmlnew);
    28. textCursor().insertFragment(fragment);
    29. emit IncommingHTML();
    30. return;
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,351
    Thanks
    3
    Thanked 5,005 Times in 4,784 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    Patrick, how is the code you pasted related to the problem? The guy just said his QMimeData doesn't contain "text/html", so why the hell do you paste code which runs some tidy clone on html code? How is that relevant?

  8. #8
    Join Date
    Apr 2006
    Posts
    31
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    Quote Originally Posted by wysota View Post
    How is that relevant?
    It helps me a little bit. I see now, that the Clipboard on OSX can hold text/plain and text/html at the same time and that Qt/Mac (even Qt 4.2.1) and my code work as expected. So it seems that I have to ask at the project pages of the relevant browsers.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,351
    Thanks
    3
    Thanked 5,005 Times in 4,784 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Is there a known problem with QMimeData on Mac OS X?

    Quote Originally Posted by Wurgl View Post
    I see now, that the Clipboard on OSX can hold text/plain and text/html at the same time and that Qt/Mac and my code work as expected. So it seems that I have to ask at the project pages of the relevant browsers.
    Have you seen the "dropsite" example (or demo) bundled with Qt? It's useful for testing mime-types of dragged objects and dragging and pasting from clipboard is using the same technique (you can probably even modify the example to react on pasting as well). And you can see what mime-types are created when you drag data from these applications.

Similar Threads

  1. problem with opengl, zooming, drawpixels, and origin
    By ntp in forum General Programming
    Replies: 0
    Last Post: 22nd February 2008, 21:48
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  3. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  4. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.