In my QGIS plugin I want to get the path of my plugin. As yet I done this so:

QDir appDir=QDir(QCoreApplication::applicationDirPath());
QString sPluginFile=appDir.path()+"/apps/qgis/plugins/plugin.dll";

Since QGIS LTR sometimes the plugin.dll is located at


so my code above is not working anymore. Has anobody an idea how to get the path from where QGIS my plugin has loaded?


After found the class QgsPluginRegistry it seems to be very easy to get the complete path of my dll:

    #include "qgspluginregistry.h"
    QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance();
    QString library = pRegistry->library( "name_of_my_plugin" );

But this class is not offered to the API, had to search it in the sources of QGIS!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.