zuck
19th April 2010, 17:21
Hi, I've made a library with a couple of QObject-derived classes.
I want to create a qml module to import in QML files (with the unique beta-release of QtDeclarative for Qt 4.6.0).
I've used QML_DECLARE_TYPE and QML_DEFINE_TYPE to export my classes.
myclass.h
class MYLIBSHARED_EXPORT MyClass : public QObject
{
Q_OBJECT
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged)
// ...
};
QML_DECLARE_TYPE(MyClass)
myclass.cpp
#include "myclass.h"
// ...
QML_DEFINE_TYPE(MyLibrary, 1,0, MyClass, MyClass)
mylibrary.pro
QT += declarative
TEMPLATE = lib
DEFINES += MYLIBSHARED_LIBRARY
HEADERS += myclass.h
SOURCES += myclass.cpp
Now i want to link this library in another project and write something like this:
example.qml
import MyLibrary 1.0
MyClass {
}
How can i do this?
Thanks!
I want to create a qml module to import in QML files (with the unique beta-release of QtDeclarative for Qt 4.6.0).
I've used QML_DECLARE_TYPE and QML_DEFINE_TYPE to export my classes.
myclass.h
class MYLIBSHARED_EXPORT MyClass : public QObject
{
Q_OBJECT
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged)
// ...
};
QML_DECLARE_TYPE(MyClass)
myclass.cpp
#include "myclass.h"
// ...
QML_DEFINE_TYPE(MyLibrary, 1,0, MyClass, MyClass)
mylibrary.pro
QT += declarative
TEMPLATE = lib
DEFINES += MYLIBSHARED_LIBRARY
HEADERS += myclass.h
SOURCES += myclass.cpp
Now i want to link this library in another project and write something like this:
example.qml
import MyLibrary 1.0
MyClass {
}
How can i do this?
Thanks!