Non static image plugin
The class declaration in the header file (.h) is missing the Q_OBJECT macro.
class MskPlugin : public QImageIOPlugin
QStringList keys() const;
Tried that; it had no effect. And, none of the example plugins have Q_OBJECT. For example, here's the plugin def for the 'ICO' file type:
@class QICOPlugin : public QImageIOPlugin
QStringList keys() const;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
The code looks ok so far. I just tried with my own plugin, it gets called and I don't get any errors (despite my actual read method not being implemented yet and thus returning and empty image :) )
Interesting. Can you give me some more info about your config? Version? iDE you used, What file type you defined, please. Mine is 4.7.4 64 bit and VS 2010
I'm using the Mac, Qt 4.8.0. But this shouldn't be a problem.
Do you get any output on the console? Some warnings, etc.?
QObject::moveToThread: Current thread (0x1f2a7b0) is not the object's thread (0x398450).
Cannot move to target thread (0x1f2a7b0)
Although, I cant, for the life of me, see how it relates.
So, you have threads involved. That complicates things.
As a first step: Cut down your application to just the imageformat plugin and a very, very simple test application. No threads, no fancy GUI. Just a dialog containing a label and three lines to set an image on the label - setPixmap(QPixmap::fromImage(xxx)). Nothing more.
If that works, move on to a bigger project. If not, feel free to come back here, of course :)
Ummm... Well first, I don't use threads in my app -- that's why the message seemed strange. And secondly, your suggestion is exactly where I am, now. Here is my app currently (minus the 'main.cpp which is the generic app startup for a single dialog):
QIMskTest::QIMskTest(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
QImage* mskImg = new QImage(mskFp);
QPixmap mskPmp = QPixmap::fromImage(*mskImg);
The moveToThread error message is caused by this code, at line 239 in 'qfactoryloader.cpp:
Which, in turn is called by line 292 in qimagereader.cpp:
@ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QString::fromLatin1(suffix)));
It's trying to get a plugin pointer for my DLL class so it can call the 'create' method. The thread error causes the above line to return zero for 'plugin', and hence, none of my other plugin classes gets called.
Do you have another library in use which sneaks in the secondary thread? Do you load the plugin manually or do you leave it delegated to the image I/O system?
My plugin is not yet ready to be published, so I cannot offer something to test and compare for you.
No, what you see is what I have. There's just the one form, with the single label on it. I have no other threads defined, and I don't use another library. I do not load the plugin manually; QT loads is automatically.
Sorry to "up" this old thread...
Steve, did you solve your problem?
I have the same message with my custom image plugin. the only thing I had found is that there is some mismatch with Qt versions (4.7.4 and 4.8.0 installed...). And my plugin is nether recognised (QImageReader::supportedImageFormats does not return my image format).
This fantastic Flip Image Plugin lets me design the back of my photo to complement the text I put there. It offers a great choice of colors and fonts. Way to go Flip Image!