Hi This question applies to Mac OSX. I'm using Qt 4.8.1 on Mac OS 10.6.8.
In my application, I wish to handle tiff clipboard data (of UTI type public.tiff) different than the implementation in QMacPasteboardMimeTiff (I don't want the data to pass through a QImage). I have written my own subclass of QMacPasteboardMime that does exactly what I want, and it works correctly. The documentation of QMacPasteboardMime ( http://qt-project.org/doc/qt-4.8/qmacpasteboardmime.html) states: "When working with MIME data, Qt will interate through all instances of QMacPasteboardMime to find an instance that can convert to, or from, a specific MIME type. It will do this by calling canConvert() on each instance, starting with (and choosing) the last created instance first. The actual conversions will be done by using convertToMime() and convertFromMime()." I am instantiating my subclass of QMacPasteboardMime (call it MyMacPasteboardMimeTiff) after my application's QApplication object is created (the base QMacPasteboardMime class is created in the QApplication initialization code). My problem is that my MyMacPasteboardMimeTiff::mimeFor(), canConvert(), etc. methods never get called. This is because QMacPasteboardMime::flavorToMime(), which gets called when QMimeData::formats() is called, uses this code: QString QMacPasteboardMime::flavorToMime(uchar t, QString flav) { MimeList *mimes = globalMimeList(); for(MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) { #ifdef DEBUG_MIME_MAPS qDebug("QMacMIme::flavorToMime: attempting %s (%d) for flavor %d[%c%c%c%c] [%s]", (*it)->convertorName().toLatin1().constData(), (*it)->type & t, flav, (flav >> 24) & 0xFF, (flav >> 16) & 0xFF, (flav >> 8) & 0xFF, (flav) & 0xFF, (*it)->mimeFor(flav).toLatin1().constData()); #endif if((*it)->type & t) { QString mimeType = (*it)->mimeFor(flav); if(!mimeType.isNull()) return mimeType; } } return QString(); } So contrary to what the documentation states/implies, QMacPasteboardMimeTiff::mimeFor() ends up getting called before MyMacPasteboardMimeTiff::mimeFor() gets called. Since QMacPasteboardMimeTiff supports the public.tiff UTI, it ends up being used to do the conversion from the clipboard's data to MIME data. If I instantiate my MyMacPasteboardMimeTiff class before the QApplication object is initialized, then my class gets called to do conversion of public.tiff data on the clipboard (that's how I know that my class works). However, if any QMacPasteboardMime subclasses are instantiated before QMacPasteboardMime::initialize() is called, none of Qt's QMacPasteboardMime subclasses will get instantiated (though I might be able to instantiate them all on my own, but that is a hack and even then the cleanup_mimes function wouldn't get called to clean them all up). Am I missing something? It really seems to me that QMacPasteboardMime::flavorToMime() should be iterating in reverse, not forward, as the documentation suggests. But I suspect that "fixing" that behavior could break the behavior of working applications so won't happen. Thanks for any help Adam
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest