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. [SOLVED]my Inherited QImageIOPlugin doesn't work!
QtWS25 Last Chance

[SOLVED]my Inherited QImageIOPlugin doesn't work!

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.7k Views
  • 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.
  • N Offline
    N Offline
    NarimanN2
    wrote on last edited by
    #1

    I wrote a plugin called TextImage and I want to use it when I save or load any image with "ti" format...

    here is my .pro File :

    @#-------------------------------------------------

    Project created by QtCreator 2014-09-09T12:01:08

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = textimage
    TEMPLATE = lib
    CONFIG += plugin release
    VERSION = 1.0.0

    SOURCES +=
    textimageplugin.cpp
    textimagehandler.cpp

    HEADERS +=
    textimageplugin.h
    textimagehandler.h

    target.path += $$[QT_INSTALL_PLUGINS]/imageformats
    INSTALLS += target

    FORMS +=

    OTHER_FILES +=
    textimage.json
    @

    with target.path += $$[QT_INSTALL_PLUGINS]/imageformats part, I expect that every time I use save or load function for Qimages with "ti" format it works properly! but it doesn't work at all! I checked imageformats folder and there is not a copy of my plugin! what is wrong?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      Depends on your OS. If you are using say linux or osx for example chances are you would need root access to install a plugin into Qt.

      I would also highly recommend against installing your plugin into your Qt directory. It should go somewhere else and be added to any project that uses it.

      As for why it isn't working, there could be a million reasons. I'd start with the fact that the plugin isn't in the directory you expect and that it probably isn't loaded into your test application properly.

      Start by including it in your test project and then making sure it is loaded properly.

      "Here":http://qt-project.org/doc/qt-5/deployment-plugins.html is the documentation you need to get your plugin both deployed and working in a test app.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NarimanN2
        wrote on last edited by
        #3

        seems like I can't load any kind of plugins! I wrote a simple plugin and a tester and tried to load it with QPluginLoader but the instance function always return null... :( reading the documentation didn't help me either!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

          Well there are a few possibilities that would cause that.

          1. You may have built your plugin with a version of Qt older than the one your app is built with. I doubt this is the problem but thought I'd mention it.

          2. You may have built a debug plugin and a release app, or vice versa. Make sure you match debug and release of plugins and application.

          3. You are loading your plugin wrong, I am adding some code to load a custom plugin explicitly:

          @
          QDir pluginsDir(QApplication::applicationDirPath());
          pluginsDir.cd("plugins"); // plugin path is /path/to/my/app/plugins

          // this loop loads all the plugins in the plugins dir
          foreach (QString filename, pluginsDir.entryList(QDir::Files))
          {
          qDebug() << "Trying to load plugin: " << filename;
          QPluginLoader pl(pluginsDir.absoluteFilePath(filename));
          QObject *plugin = pl.instance();
          if (plugin)
          {
          qDebug() << "Plugin loaded";
          }
          else
          {
          qDebug() << "Failed to load plugin, error: " << pl.errorString();
          }
          }
          @

          I typed out that code in this edit box so hopefully it's error free and compiles. :)

          Make sure you create a directory called plugins in your application launch directory and put your plugin(s) in there.

          For example:

          cd /my/app/path

          mkdir plugins

          ls -l

          Should show your app and the plugins dir.

          cp /path/to/my/plugin /my/app/path/plugins

          ls -l /my/app/path/plugins

          Should show your plugin in that directory.

          Run the example on the console so you can see the qDebug() results.

          I just realized I assumed a posix environment in my example commands, translate to windows if you are using that os.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ambershark
            wrote on last edited by
            #5

            Oh and 1 more super important thing, make sure you have the following in your plugin pro file:

            @
            TEMPLATE = lib
            CONFIG += plugin
            @

            EDIT: the above may not be true anymore. This might be old Qt4 knowledge rattling around in my head. It may still be required but I can't remember now. Also "here":http://qt-project.org/doc/qt-5/plugins-howto.html is a good document on creating plugins you should read.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NarimanN2
              wrote on last edited by
              #6

              thanks. it worked!

              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