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. I am searching plugins skeleton
Forum Updated to NodeBB v4.3 + New Features

I am searching plugins skeleton

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 747 Views 2 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 last edited by
    #1

    I want write code editor based on QPlainTextEdit and highlighters from https://github.com/KDE/syntax-highlighting.
    I prefer modular form with plugins. Plugin must be loaded/unloaded dynamically. In editor wil multitab with editor factory. Plugins for syntax highlight, theme, type correctness, encryption for encrypted documents...
    How can I write framework and plugins?

    KazuoAsanoK aha_1980A 2 Replies Last reply
    0
    • A AndrzejB

      I want write code editor based on QPlainTextEdit and highlighters from https://github.com/KDE/syntax-highlighting.
      I prefer modular form with plugins. Plugin must be loaded/unloaded dynamically. In editor wil multitab with editor factory. Plugins for syntax highlight, theme, type correctness, encryption for encrypted documents...
      How can I write framework and plugins?

      KazuoAsanoK Offline
      KazuoAsanoK Offline
      KazuoAsano
      Qt Champions 2018
      wrote on last edited by
      #2

      @AndrzejB ,
      I have never tried it, but I think that QPluginLoader Class can be used.
      so please refer sample document as below.

      • Qt Documentation: Echo Plugin Example
      • Qt Documentation: QPluginLoader Class
      1 Reply Last reply
      4
      • A AndrzejB

        I want write code editor based on QPlainTextEdit and highlighters from https://github.com/KDE/syntax-highlighting.
        I prefer modular form with plugins. Plugin must be loaded/unloaded dynamically. In editor wil multitab with editor factory. Plugins for syntax highlight, theme, type correctness, encryption for encrypted documents...
        How can I write framework and plugins?

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @AndrzejB you can also have a look at QtCreators sorce code, as it does much of what you want.

        Please note that plugins should not be unloaded, and I think it is rarely useful.

        Qt has to stay free or it will die.

        1 Reply Last reply
        3
        • ModelTechM Offline
          ModelTechM Offline
          ModelTech
          wrote on last edited by ModelTech
          #4

          I have created dynamically loaded plugins for my application by following the Plug & Paint example. This example uses QPluginLoader for loading the plugins at run-time. One thing that turned out to be a bit more tricky than I anticipated based on the example is to identify the correct plugin path on the various platforms. So, here is a bit of my code that covers the Loading part:

              QDir PluginLocation = QDir(qApp->applicationDirPath());
          
              #if defined(Q_OS_WIN)
                  if (PluginLocation.dirName().toLower() == "debug" || PluginLocation.dirName().toLower() == "release")
                      PluginLocation.cdUp();
              #elif defined(Q_OS_MAC)
                  QDir PackageLocation = QDir(qApp->applicationDirPath());
                  PackageLocation.cdUp();
                  PackageLocation.cdUp();
                  PackageLocation.cdUp();
                  PackageLocation.cdUp();
                  if (PackageLocation.dirName().toLower() == "debug" || PackageLocation.dirName().toLower() == "release") {
                      PluginLocation.cdUp();
                      PluginLocation.cdUp();
                      PluginLocation.cdUp();
                      PluginLocation.cd("plugins");
                  } else {
                      PluginLocation.cdUp();
                      PluginLocation.cd("PlugIns");
                  }
              #endif
          
              #if not defined (Q_OS_MAC)
                  PluginLocation.cd("plugins");
              #endif
          
              foreach (QString FileName, PluginLocation.entryList(QDir::Files)) {
                  if (QLibrary::isLibrary(FileName)) {
                      QPluginLoader Loader(PluginLocation.absoluteFilePath(FileName));
                      QObject *Plugin = Loader.instance();
                      if (Plugin) {
                          // Do something useful with the plugin as in Plug & Paint example
                      }
                  }
              }
          
          1 Reply Last reply
          2
          • A Offline
            A Offline
            AndrzejB
            wrote on last edited by
            #5

            Mac binary directory is so deep ? - (n times PackageLocation.cdUp())

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              No it's not, the binary is by default in MyApp.app/Content/MacOS while the plugins are in MyApp.app/Content/PlugIn. You may modify some of that however following the recommended layout (as Qt does for you) is way simpler.

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

              ModelTechM 1 Reply Last reply
              2
              • SGaistS SGaist

                Hi,

                No it's not, the binary is by default in MyApp.app/Content/MacOS while the plugins are in MyApp.app/Content/PlugIn. You may modify some of that however following the recommended layout (as Qt does for you) is way simpler.

                ModelTechM Offline
                ModelTechM Offline
                ModelTech
                wrote on last edited by
                #7

                @SGaist That is indeed correct when deploying the app but not when running from QtCreator. Hence, this not so nice construction... If anybody has a nicer solution, I am all ears :)

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  To be sure we're on the same idea, you would like to have them at the correct place when you build your application ?

                  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
                  0

                  • Login

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