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. How to use Qt plugins?
Forum Updated to NodeBB v4.3 + New Features

How to use Qt plugins?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 594 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.
  • A Offline
    A Offline
    AndrzejB
    wrote on 6 Apr 2022, 16:10 last edited by
    #1

    I start creating BPG image plugin. I see https://github.com/FreeSlave/qt-sprite-image-plugin as example.

    1. How use plugins? For example in my ImageViewer, is possible dynamic register ?
    2. How register in system , for GwenView? only in KDE?
    3. What about versions Qt main program and version Qt used to create plugins ? May be different?
    C 1 Reply Last reply 6 Apr 2022, 16:42
    0
    • A Offline
      A Offline
      AndrzejB
      wrote on 6 Apr 2022, 20:28 last edited by AndrzejB 4 Jul 2022, 09:54
      #5

      Now, is Qt5 error in

      Q_EXPORT_STATIC_PLUGIN(ArgbPlugin)
      Q_EXPORT_PLUGIN2(argb, ArgbPlugin)
      

      Now I found solution:
      https://stackoverflow.com/questions/22394477/how-to-create-plugins-qt-5-2-0

      Where must be folder imageformats? What is QT_INSTALL_PLUGINS ?
      How call install, how migrate from .pro to cmake?
      Solved where folder:
      https://www.qtcentre.org/threads/46927-Location-of-imageformats-directory

      1 Reply Last reply
      0
      • A AndrzejB
        6 Apr 2022, 16:10

        I start creating BPG image plugin. I see https://github.com/FreeSlave/qt-sprite-image-plugin as example.

        1. How use plugins? For example in my ImageViewer, is possible dynamic register ?
        2. How register in system , for GwenView? only in KDE?
        3. What about versions Qt main program and version Qt used to create plugins ? May be different?
        C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 6 Apr 2022, 16:42 last edited by
        #2

        @AndrzejB said in How to use Qt plugins?:

        How use plugins? For example in my ImageViewer, is possible dynamic register ?

        No need to register something - the plugin just has to be where the Qt version you're using for your program is looking for plugins

        How register in system , for GwenView? only in KDE?

        See above

        What about versions Qt main program and version Qt used to create plugins ? May be different?

        The plugin should have compiled with the same Qt version. Plugins compiled with an older version should work too when the main Qt version matches.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • A Offline
          A Offline
          AndrzejB
          wrote on 6 Apr 2022, 17:22 last edited by
          #3

          I read plugins:

          QDir pluginsDir(QApplication::applicationDirPath());
              pluginsDir.cd("plugins");
              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();
                  }
              }
          

          next I read mime, but not bpg in my list

              QStringList mimeTypeFilters;
              const QByteArrayList supportedMimeTypes = acceptMode == QFileDialog::AcceptOpen
                  ? QImageReader::supportedMimeTypes() : QImageWriter::supportedMimeTypes();
              for (const QByteArray &mimeTypeName : supportedMimeTypes) {
                  //const char* s = QString(mimeTypeName).toStdString().c_str();
                  mimeTypeFilters.append(mimeTypeName);
              }
              mimeTypeFilters.sort();
              dialog.setMimeTypeFilters(mimeTypeFilters);
              dialog.selectMimeTypeFilter("image/bpg");
          

          Plugin has json:

          {
              "Keys" : [ "bpg" ],
              "MimeTypes" : ["image/bpg",]
          }
          
          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 6 Apr 2022, 18:28 last edited by
            #4

            Hi,

            The image format plugins should be in a folder named imageformats.

            See this Qt Quarterly article.

            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
            1
            • A Offline
              A Offline
              AndrzejB
              wrote on 6 Apr 2022, 20:28 last edited by AndrzejB 4 Jul 2022, 09:54
              #5

              Now, is Qt5 error in

              Q_EXPORT_STATIC_PLUGIN(ArgbPlugin)
              Q_EXPORT_PLUGIN2(argb, ArgbPlugin)
              

              Now I found solution:
              https://stackoverflow.com/questions/22394477/how-to-create-plugins-qt-5-2-0

              Where must be folder imageformats? What is QT_INSTALL_PLUGINS ?
              How call install, how migrate from .pro to cmake?
              Solved where folder:
              https://www.qtcentre.org/threads/46927-Location-of-imageformats-directory

              1 Reply Last reply
              0

              1/5

              6 Apr 2022, 16:10

              • Login

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