Skip to content

Instantly share code, notes, and snippets.

@usagi
Last active December 10, 2015 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usagi/4467883 to your computer and use it in GitHub Desktop.
Save usagi/4467883 to your computer and use it in GitHub Desktop.
#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()
{
}
#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
module com.mycompany.qmlcomponents
plugin untitled
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
}
#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");
}
#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