Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Non static image plugin
Forum Updated to NodeBB v4.3 + New Features

Non static image plugin

Scheduled Pinned Locked Moved General and Desktop
18 Posts 4 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goetz
    wrote on last edited by
    #6

    The class declaration in the header file (.h) is missing the Q_OBJECT macro.

    @
    QT_BEGIN_NAMESPACE

    class MskPlugin : public QImageIOPlugin
    {
    Q_OBJECT
    public:
    QStringList keys() const;
    @

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SteveBooth
      wrote on last edited by
      #7

      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
      {
      public:
      QStringList keys() const;
      Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
      QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
      };
      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #8

        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 :) )

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SteveBooth
          wrote on last edited by
          #9

          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

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #10

            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.?

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SteveBooth
              wrote on last edited by
              #11

              Yes, actually:

              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.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #12

                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 :)

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SteveBooth
                  wrote on last edited by
                  #13

                  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):

                  @#include "qimsktest.h"

                  #include "qfileinfo.h"

                  #include "qpluginloader.h"
                  #include "qlibrary.h"
                  #include "qimageiohandler.h"

                  QIMskTest::QIMskTest(QWidget *parent, Qt::WFlags flags)
                  : QMainWindow(parent, flags)
                  {
                  ui.setupUi(this);

                  QString mskFp("...0012.msk");

                  QImage* mskImg = new QImage(mskFp);

                  QPixmap mskPmp = QPixmap::fromImage(*mskImg);

                  ui.mskImg->setPixmap(sMskPmp);
                  }

                  QIMskTest::~QIMskTest()
                  {

                  }
                  @

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SteveBooth
                    wrote on last edited by
                    #14

                    The moveToThread error message is caused by this code, at line 239 in 'qfactoryloader.cpp:

                    @ obj->moveToThread(QCoreApplicationPrivate::mainThread());@

                    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.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #15

                      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.

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SteveBooth
                        wrote on last edited by
                        #16

                        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.

                        1 Reply Last reply
                        0
                        • N Offline
                          N Offline
                          Nmut
                          wrote on last edited by
                          #17

                          Hi guys

                          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).

                          Regards,
                          Nmut.

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            KarolDuke
                            wrote on last edited by
                            #18

                            Hello

                            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!

                            http://wordpress.org/extend/plugins/wp-flip-image-free

                            Thanks.

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved