Last active
December 10, 2015 17:28
-
-
Save usagi/4467883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "myitem.hxx" | |
MyItem::MyItem(QQuickItem *parent): | |
QQuickItem(parent) | |
{ | |
// By default, QQuickItem does not draw anything. If you subclass | |
// QQuickItem to create a visual item, you will need to uncomment the | |
// following line and re-implement updatePaintNode() | |
// setFlag(ItemHasContents, true); | |
} | |
MyItem::~MyItem() | |
{ | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module com.mycompany.qmlcomponents | |
plugin untitled | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEMPLATE = lib | |
TARGET = untitled | |
QT += qml quick | |
CONFIG += qt plugin | |
TARGET = $$qtLibraryTarget($$TARGET) | |
uri = com.mycompany.qmlcomponents | |
# Input | |
SOURCES += \ | |
untitled_plugin.cxx \ | |
myitem.cxx | |
HEADERS += \ | |
untitled_plugin.hxx \ | |
myitem.hxx | |
OTHER_FILES = qmldir | |
!equals(_PRO_FILE_PWD_, $$OUT_PWD) { | |
copy_qmldir.target = $$OUT_PWD/qmldir | |
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir | |
copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" | |
QMAKE_EXTRA_TARGETS += copy_qmldir | |
PRE_TARGETDEPS += $$copy_qmldir.target | |
} | |
qmldir.files = qmldir | |
unix { | |
installPath = $$[QT_INSTALL_IMPORTS]/$$replace(uri, \\., /) | |
qmldir.path = $$installPath | |
target.path = $$installPath | |
INSTALLS += target qmldir | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "untitled_plugin.hxx" | |
#include "myitem.hxx" | |
#include <qqml.h> | |
void UntitledPlugin::registerTypes(const char *uri) | |
{ | |
// @uri com.mycompany.qmlcomponents | |
qmlRegisterType<MyItem>(uri, 1, 0, "MyItem"); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UNTITLED_PLUGIN_H | |
#define UNTITLED_PLUGIN_H | |
#include <QQmlExtensionPlugin> | |
class UntitledPlugin : public QQmlExtensionPlugin | |
{ | |
Q_OBJECT | |
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | |
public: | |
void registerTypes(const char *uri); | |
}; | |
#endif // UNTITLED_PLUGIN_H | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment