Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to handle pointers in plugins,or abstract classes
Qt 6.11 is out! See what's new in the release blog

How to handle pointers in plugins,or abstract classes

Scheduled Pinned Locked Moved C++ Gurus
2 Posts 2 Posters 1.6k 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.
  • K Offline
    K Offline
    karim24
    wrote on last edited by
    #1

    interface.h
    @
    ...
    interface();//constructor
    virtual void setNum(int*)=0;
    ...
    @

    plugin.cpp
    @
    ...
    public:
    void setNum(int *i){
    num=i;
    }
    private:
    int *num;
    @

    i will load the plugin using QPluginLoader,then create an instance from the interface
    @QObject * QPluginLoader::instance()@

    so how to handle the memory and prevent memory leak?how do i delete the instances i create?

    Edit:
    if i delete the pointer in the destructor of "plugin class"

    will the destructor "plugin class" be called when calling @bool QPluginLoader::unload()@

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's described in the documentation "here":http://qt-project.org/doc/qt-5/QPluginLoader.html#details and "here":http://qt-project.org/doc/qt-5/qpluginloader.html#instance

      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