Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Building a Qt Image Plugin throws "invalid new-expression of abstract class type 'ArgbHandler'" error

    General and Desktop
    2
    11
    6622
    Loading More Posts
    • 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.
    • H
      Hans last edited by SGaist

      Hi,
      i tried to compile a QT Image Plugin. I used the tutorial here. But it is quite old. And I cannot find a new version.

      http://doc.qt.digia.com/qq/qq17-imageio.html

      Here are the code snippets that belongs to the error message:

      class ArgbPlugin : public QImageIOPlugin
      {
        QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
      };
      
      QImageIOHandler *ArgbPlugin::create( QIODevice *device, const QByteArray &format) const
      {
          QImageIOHandler *handler = new ArgbHandler;
          handler->setDevice(device);
          handler->setFormat(format);
          return handler;
      }
      
      class ArgbHandler : public QImageIOHandler
      {
      public:
          ArgbHandler();
          ~ArgbHandler();
       
      // some methods are following....
      };
      

      Maybe someone can give me a hint.

      I dont know how to append a file here in the forum. I could also send the whole qt project.

      I am using QT 5.4.1 ,QT Creator 3.3.1 on windows 7 64 bit.

      [edit: added missing coding tags SGaist]

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Did you implement both read and canRead in ArgbHandler ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • H
          Hans last edited by

          Hi,
          thanks for your help. :)

          I will put the code to pastbin so it is easier to read.

          http://pastebin.com/8hc1Fv5g
          http://pastebin.com/DGxztH81
          http://pastebin.com/DuRkrkva
          http://pastebin.com/bpV8hgkC

          http://pastebin.com/jcdQgw4c

          I think read and canRead are put in properly.

          1 Reply Last reply Reply Quote 0
          • H
            Hans last edited by Hans

            Here I also uploaded the whole source.

            http://www.file-upload.net/download-10397238/ARGB2.zip.html

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              canRead is not implemented nor called properly

              It isn't a static function (which you can't override by the way)

              bool ArgbHandler::canRead() const
              {
                  return device()->peek(4) == "\xCA\xFE\x12\x34";
              }
              
              class ArgbHandler : public QImageIOHandler
              {
              public:
                  ArgbHandler();
                  ~ArgbHandler();
              
                  bool read(QImage *image);
                  bool write(const QImage &image);
              
                  bool canRead() const;
              
                  QVariant option(ImageOption option) const;
                  void setOption(ImageOption option, const QVariant &value);
                  bool supportsOption(ImageOption option) const;
              };
              

              which builds properly, however, I haven't done any run tests. You would also need to correct ArgbPlugin::capabilities for your plugin to build properly

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 0
              • H
                Hans last edited by

                Hi,
                thanks for your quick answer.

                I could also compile it. My intension for the plugin was to get support for the OpenEXR file format in qt. I compiled the OpenEXR libs but i have not found a good tutorial how to finally connect them with the compiled plugin so I can load exr files as a QImage.

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  Do you mean get the data from an OpenEXR image in QImage or use the plugin ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply Reply Quote 0
                  • H
                    Hans last edited by

                    yes, basically I want to load an OpenEXR image in QImage. The format is not supported. Therefore I wanted to use the plugin.

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      Sorry, I meant, do you have problem getting the plugin to load ? Or do you have problem to read images from an OpenEXR file ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply Reply Quote 0
                      • H
                        Hans last edited by

                        The plugin is loading correctly. I created a new simple QT app there i created a QImage.

                        I add the plugin via: QCoreApplication::addLibraryPath("some_path/plugins");

                        The app runs without an error.

                        But my problem is how can read an Open EXR image now. I guess I have to include the Openexr libs and use some special code for exr?

                        1 Reply Last reply Reply Quote 0
                        • SGaist
                          SGaist Lifetime Qt Champion last edited by

                          Yes, you will need to convert your EXR images in something supported by QImage

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post