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. Plugin with non-virtual functions?
Forum Updated to NodeBB v4.3 + New Features

Plugin with non-virtual functions?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k 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.
  • D Offline
    D Offline
    dustije
    wrote on 2 Mar 2013, 15:48 last edited by
    #1

    I want to write some plugins for my application with non-virtual functions. In the "documentation for the plugins system":http://qt-project.org/doc/qt-4.8/plugins-howto.html it says "Define a set of interfaces (classes with only pure virtual functions) used to talk to the plugins." So i think it's not possible to have non-virtual functions in a plugin. Is there antoher way of implementing a plugin interface with some code in it? Do i really have to write the same in every plugin i write?
    Thanks in advance!

    1 Reply Last reply
    0
    • U Offline
      U Offline
      utcenter
      wrote on 2 Mar 2013, 16:09 last edited by
      #2

      You only need virtuals for the interface, you don't have to use virtual functions everywhere in your plugin code. So don't worry about performance impact.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dustije
        wrote on 3 Mar 2013, 13:39 last edited by
        #3

        Sorry, my bad, i did not explain it well.
        I want to have a plugin system in my program. I want to create a "assembly line" with the plugins which means there will be messages (=QStrings) passed from one plugin to the next and then each plugin can do some operations on the QString (it's a little bit more complicated but this is the basic function). Since every plugin needs to do some operations before it can process the QString i thought it wouldn't be good style to write the same operations in each plugin, especially if i make the interface for the plugin open source so everyone can write plugins for my programm. What i want to do is to put some code directly into the interface so the derived plugins don't have to bother with that code. Now in the documentary it says “Define a set of interfaces (classes with only pure virtual functions) used to talk to the plugins” so this is my problem. How can i put some code into the interface (not into the derived plugins, but directly into the interface)? E.g. every plugin has a private QString "name" with a setter & getter. But since the getter & setter are not virtual, (i think) the interface isn't a real interface for the plugin system anymore.
        I hope this explanation is makes it more clear what my problem is, if not, please ask!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Mar 2013, 12:03 last edited by
          #4

          Hi,

          You need to make "pure virtual" only the functions that have to be reimplemented. If you have a set of common function for your object, there is nothing wrong with having them implemented.

          Have a look at the plugin documentation, if you take ie QAccessiblePlugin, it inherits from QObject, so it does have a set of defined function as well as a pure virtual interface.

          Hope it helps

          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

          1/4

          2 Mar 2013, 15:48

          • Login

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