Some time ago I wrote a post how to port QtQuick1.X extensions to Qt5. In that post, I wrote how I created a VideoWidget QMLExtensionPlugin on Qt 4.7 and then what it takes to make it run on Qt5 too. Well, things has changed a bit since that post an I thought that I should share what it takes now to make it work again.
Step 1: You can remove deprecated macro Q_EXPORT_PLUGIN2() from your plugin code
Step 2: Add a new macro Q_PLUGIN_METADATA(IID “module.uri” FILE “yourfile.json”) after Q_OBJECT macro in your extension plugin class.
#ifndef VIDEOWIDGET_QML_PLUGIN_PLUGIN_H
#define VIDEOWIDGET_QML_PLUGIN_PLUGIN_H
#include <QtQml/QQmlExtensionPlugin>
class VideoWidget_QML_PluginPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.dpointer.media" FILE "videowidget.json")
public:
void registerTypes(const char *uri);
};
#endif // VIDEOWIDGET_QML_PLUGIN_PLUGIN_H
Step 3: Add JSON file to your project e.g. using OTHER_FILES = videowidget.json
{
"Keys": [ "VideoWidget" ]
}
If I remembered everything, that’s all folks. You may also want to checkout the instructions from http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5
This post was a short and fast, but I hope it will help other devs who are using a bleeding edge Qt5 too. And if you have followed the news, Qt5 Beta is out!
Thanks for reading my blog!