Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

How to get to work c++ qml extension.

$
0
0
Hello! The issue goes during porting my plugin to 4.8.h to 5.0.2. Utility qmlplugindump.exe gives me errors, but not correct types file. So i`l try to create empty plugin from QtCreator templates. So, here is the generated code #ifndef MYITEM_H #define MYITEM_H #include <QQuickItem>   class MyItem : public QQuickItem {     Q_OBJECT     Q_DISABLE_COPY(MyItem) public:     MyItem(QQuickItem *parent = 0);     ~MyItem(); }; QML_DECLARE_TYPE(MyItem)   #endif // MYITEM_H #include "myitem.h"   MyItem::MyItem(QQuickItem *parent):   QQuickItem(parent){} MyItem::~MyItem() {} #ifndef SAMPLEX_PLUGIN_H #define SAMPLEX_PLUGIN_H   #include <QQmlExtensionPlugin>   class SampleXPlugin : public QQmlExtensionPlugin {     Q_OBJECT     Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")     public:     void registerTypes(const char *uri); };   #endif // SAMPLEX_PLUGIN_H #include "samplex_plugin.h" #include "myitem.h"   #include <qqml.h>   void SampleXPlugin::registerTypes(const char *uri) {     // @uri com.mycompany.qmlcomponents     qmlRegisterType<MyItem>(uri, 1, 0, "MyItem"); } and qmldir module com.mycompany.qmlcomponents plugin SampleX and pro file TEMPLATE = lib TARGET = SampleX QT += qml quick CONFIG += qt plugin   TARGET = $$qtLibraryTarget($$TARGET) uri = com.mycompany.qmlcomponents   # Input SOURCES += \     samplex_plugin.cpp \     myitem.cpp   HEADERS += \     samplex_plugin.h \     myitem.h   OTHER_FILES = qmldir After compiling i`l try to execute qmlplugindump (in the folder there qmldir and dll): qmlplugindump com.mycompany.qmlcomponents 1.0 QQmlComponent: Component is not ready "file:///typelist.qml:2:1: module "com.mycompany.qmlcomponents" is not installed" qmlplugindump com.mycompany.qmlcomponents 1.0 ./SampleX.dll QQmlComponent: Component is not ready file:///D:/tmp/c/qt/untitled3/qmldir: plugin cannot be loaded for module "": Module namespace 'com.mycompany.qmlcompone nts' does not match import URI ''" If i`l using qmldir plugin SampleX and qmlplugindump -path ./ Module '' does not contain a module identifier directive - it cannot be protected from external registrations. Why? p.s. compiling with vs2010.

Viewing all articles
Browse latest Browse all 18427

Trending Articles