How to use Qt plugins?
-
I start creating BPG image plugin. I see https://github.com/FreeSlave/qt-sprite-image-plugin as example.
- How use plugins? For example in my ImageViewer, is possible dynamic register ?
- How register in system , for GwenView? only in KDE?
- What about versions Qt main program and version Qt used to create plugins ? May be different?
-
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-0Where 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 -
@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.
-
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",] }
-
Hi,
The image format plugins should be in a folder named imageformats.
See this Qt Quarterly article.
-
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-0Where 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