From: Kevin Krammer Date: Mon, 15 Oct 2012 18:44:25 +0000 (+0200) Subject: Refactoring inheritance hierachy, reduce amount of per class code X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=0d61fe26402aed2feb05c9680771f782dd14f849;p=web%2Fkonrad%2FDeclarativeWidgets.git Refactoring inheritance hierachy, reduce amount of per class code --- diff --git a/declarativeobjects.cpp b/declarativeobjects.cpp index 86899d5..d947080 100644 --- a/declarativeobjects.cpp +++ b/declarativeobjects.cpp @@ -2,9 +2,8 @@ #include "qmetaobjectbuilder_p.h" -#include - #include +#include /* if (QString(staticMetaObject.className()) == "DeclarativeLabel") { \ @@ -12,9 +11,9 @@ for (int i = 0; i < staticMetaObject.propertyCount(); ++i) { \ qDebug(" prop: %d=%s", i, staticMetaObject.property(i).name()); \ } \ - qDebug("class: DeclarativeObject"); \ - for (int i = 0; i < DeclarativeObject::staticMetaObject.propertyCount(); ++i) { \ - qDebug(" prop: %d=%s", i, DeclarativeObject::staticMetaObject.property(i).name()); \ + qDebug("class: AbstractDeclarativeObject"); \ + for (int i = 0; i < AbstractDeclarativeObject::staticMetaObject.propertyCount(); ++i) { \ + qDebug(" prop: %d=%s", i, AbstractDeclarativeObject::staticMetaObject.property(i).name()); \ } \ } \ if (QString(staticMetaObject.className()) == "DeclarativeLabel") { \ @@ -25,7 +24,7 @@ } \ */ -#define CUSTOM_METAOBJECT(ClassName, BaseType, WidgetType, WidgetVariable) \ +#define CUSTOM_METAOBJECT(ClassName, WidgetType, WidgetVariable) \ QMetaObject ClassName::staticMetaObject;\ bool ClassName::metaObjectInitialized = ClassName::initializeMetaObject(); \ bool ClassName::initializeMetaObject() \ @@ -33,7 +32,7 @@ bool ClassName::initializeMetaObject() \ QMetaObjectBuilder builder; \ const QMetaObject *mo = &WidgetType::staticMetaObject; \ builder.addMetaObject(mo); \ - builder.addMetaObject(&DeclarativeObject::staticMetaObject); \ + builder.addMetaObject(&AbstractDeclarativeObject::staticMetaObject); \ builder.setSuperClass(WidgetType::staticMetaObject.superClass()); \ builder.setClassName(""#ClassName); \ ClassName::staticMetaObject = *builder.toMetaObject(); \ @@ -55,7 +54,7 @@ int ClassName::qt_metacall(QMetaObject::Call call, int id, void **argv) \ { \ if (call == QMetaObject::ReadProperty || call == QMetaObject::WriteProperty) { \ if (id >= WidgetType::staticMetaObject.propertyCount()) { \ - id = DeclarativeObject::qt_metacall(call, id - WidgetType::staticMetaObject.propertyCount() + 1, argv); \ + id = AbstractDeclarativeObject::qt_metacall(call, id - WidgetType::staticMetaObject.propertyCount() + 1, argv); \ id += WidgetType::staticMetaObject.propertyCount() - 1; \ } else { \ id = WidgetVariable->qt_metacall(call, id, argv); \ @@ -69,68 +68,68 @@ int ClassName::qt_metacall(QMetaObject::Call call, int id, void **argv) \ return id; \ } -static void connectAllSignals(QObject *sender, QObject *receiver) +// AbstractDeclarativeObject +AbstractDeclarativeObject::AbstractDeclarativeObject(QObject *parent) + : QObject(parent) { - for (int i = 0; i < sender->metaObject()->methodCount(); ++i) { - const QMetaMethod method = sender->metaObject()->method(i); - if (method.methodType() == QMetaMethod::Signal) { - const QByteArray signature = "2" + QByteArray(method.signature()); - QObject::connect(sender, signature.data(), receiver, signature.data()); - } - } } -// DeclarativeObject -DeclarativeObject::DeclarativeObject(QObject *parent) - : QObject(parent) +AbstractDeclarativeObject::~AbstractDeclarativeObject() { } -DeclarativeObject::~DeclarativeObject() +QDeclarativeListProperty AbstractDeclarativeObject::data() { + return QDeclarativeListProperty(this, 0, AbstractDeclarativeObject::data_append, + AbstractDeclarativeObject::data_count, + AbstractDeclarativeObject::data_at, + AbstractDeclarativeObject::data_clear); } -QDeclarativeListProperty DeclarativeObject::data() +void AbstractDeclarativeObject::dataAppend(QObject *) { - return QDeclarativeListProperty(this, 0, DeclarativeObject::data_append, - DeclarativeObject::data_count, - DeclarativeObject::data_at, - DeclarativeObject::data_clear); } -void DeclarativeObject::dataAppend(QObject *) +int AbstractDeclarativeObject::dataCount() const { + return 0; } -int DeclarativeObject::dataCount() +QObject* AbstractDeclarativeObject::dataAt(int) const { return 0; } -QObject* DeclarativeObject::dataAt(int) +void AbstractDeclarativeObject::dataClear() { - return 0; } -void DeclarativeObject::dataClear() +static void connectAllSignals(QObject *sender, QObject *receiver) { + for (int i = 0; i < sender->metaObject()->methodCount(); ++i) { + const QMetaMethod method = sender->metaObject()->method(i); + if (method.methodType() == QMetaMethod::Signal) { + const QByteArray signature = "2" + QByteArray(method.signature()); + QObject::connect(sender, signature.data(), receiver, signature.data()); + } + } } -void DeclarativeObject::data_append(QDeclarativeListProperty *property, QObject *object) +void AbstractDeclarativeObject::data_append(QDeclarativeListProperty *property, QObject *object) { if (!object) return; - DeclarativeObject *that = dynamic_cast(property->object); + AbstractDeclarativeObject *that = dynamic_cast(property->object); if (that) that->dataAppend(object); else qWarning("cast went wrong in data_append"); } -int DeclarativeObject::data_count(QDeclarativeListProperty *property) +int AbstractDeclarativeObject::data_count(QDeclarativeListProperty *property) { - DeclarativeObject *that = dynamic_cast(property->object); + AbstractDeclarativeObject *that = dynamic_cast(property->object); if (that) return that->dataCount(); else { @@ -139,9 +138,9 @@ int DeclarativeObject::data_count(QDeclarativeListProperty *property) } } -QObject* DeclarativeObject::data_at(QDeclarativeListProperty *property, int index) +QObject* AbstractDeclarativeObject::data_at(QDeclarativeListProperty *property, int index) { - DeclarativeObject *that = dynamic_cast(property->object); + AbstractDeclarativeObject *that = dynamic_cast(property->object); if (that) return that->dataAt(index); else { @@ -150,9 +149,9 @@ QObject* DeclarativeObject::data_at(QDeclarativeListProperty *property, } } -void DeclarativeObject::data_clear(QDeclarativeListProperty *property) +void AbstractDeclarativeObject::data_clear(QDeclarativeListProperty *property) { - DeclarativeObject *that = dynamic_cast(property->object); + AbstractDeclarativeObject *that = dynamic_cast(property->object); if (that) that->dataClear(); else @@ -160,308 +159,117 @@ void DeclarativeObject::data_clear(QDeclarativeListProperty *property) } // DeclarativeHBoxLayout -DeclarativeHBoxLayout::DeclarativeHBoxLayout(QObject *parent) - : DeclarativeObject(parent) - , m_layout(new QHBoxLayout) +DeclarativeHBoxLayout::DeclarativeHBoxLayout(QObject *parent) : DeclarativeBoxLayout(parent) { - connectAllSignals(m_layout, this); + connectAllSignals(m_proxiedObject, this); } -DeclarativeHBoxLayout::~DeclarativeHBoxLayout() -{ - delete m_layout; -} - -QObject* DeclarativeHBoxLayout::object() -{ - return m_layout; -} - -void DeclarativeHBoxLayout::dataAppend(QObject *object) -{ - DeclarativeWidget *widget = dynamic_cast(object); - DeclarativeHBoxLayout *hboxLayout = dynamic_cast(object); - DeclarativeVBoxLayout *vboxLayout = dynamic_cast(object); - - if (widget) { - m_children.append(object); - m_layout->addWidget(qobject_cast(widget->object())); - } else if (hboxLayout) { - m_children.append(object); - m_layout->addLayout(qobject_cast(hboxLayout->object())); - } else if (vboxLayout) { - m_children.append(object); - m_layout->addLayout(qobject_cast(vboxLayout->object())); - } else { - qmlInfo(this) << "Can not contain element of type " << object->metaObject()->className(); - } -} - -int DeclarativeHBoxLayout::dataCount() -{ - return m_children.count(); -} - -QObject* DeclarativeHBoxLayout::dataAt(int index) -{ - return m_children.at(index); -} - -void DeclarativeHBoxLayout::dataClear() -{ - qDeleteAll(m_children); - m_children.clear(); -} - -CUSTOM_METAOBJECT(DeclarativeHBoxLayout, DeclarativeObject, QHBoxLayout, m_layout) +CUSTOM_METAOBJECT(DeclarativeHBoxLayout, QHBoxLayout, m_proxiedObject) // DeclarativeVBoxLayout -DeclarativeVBoxLayout::DeclarativeVBoxLayout(QObject *parent) - : DeclarativeObject(parent) - , m_layout(new QVBoxLayout) -{ - connectAllSignals(m_layout, this); -} - -DeclarativeVBoxLayout::~DeclarativeVBoxLayout() -{ - delete m_layout; -} - -QObject* DeclarativeVBoxLayout::object() -{ - return m_layout; -} - -void DeclarativeVBoxLayout::dataAppend(QObject *object) -{ - DeclarativeWidget *widget = dynamic_cast(object); - DeclarativeHBoxLayout *hboxLayout = dynamic_cast(object); - DeclarativeVBoxLayout *vboxLayout = dynamic_cast(object); - - if (widget) { - m_children.append(object); - m_layout->addWidget(qobject_cast(widget->object())); - } else if (hboxLayout) { - m_children.append(object); - m_layout->addLayout(qobject_cast(hboxLayout->object())); - } else if (vboxLayout) { - m_children.append(object); - m_layout->addLayout(qobject_cast(vboxLayout->object())); - } else { - qmlInfo(this) << "Can not contain element of type " << object->metaObject()->className(); - } -} - -int DeclarativeVBoxLayout::dataCount() -{ - return m_children.count(); -} - -QObject* DeclarativeVBoxLayout::dataAt(int index) -{ - return m_children.at(index); -} - -void DeclarativeVBoxLayout::dataClear() +DeclarativeVBoxLayout::DeclarativeVBoxLayout(QObject *parent) : DeclarativeBoxLayout(parent) { - qDeleteAll(m_children); - m_children.clear(); + connectAllSignals(m_proxiedObject, this); } -CUSTOM_METAOBJECT(DeclarativeVBoxLayout, DeclarativeObject, QVBoxLayout, m_layout) +CUSTOM_METAOBJECT(DeclarativeVBoxLayout, QVBoxLayout, m_proxiedObject) // DeclarativeWidget -DeclarativeWidget::DeclarativeWidget(QObject *parent) - : DeclarativeObject(parent) - , m_widget(new QWidget) +DeclarativeWidget::DeclarativeWidget(QObject *parent) : DeclarativeObjectProxy(parent) { - connectAllSignals(m_widget, this); -} - -DeclarativeWidget::~DeclarativeWidget() -{ - delete m_widget; -} - -QObject* DeclarativeWidget::object() -{ - return m_widget; + connectAllSignals(m_proxiedObject, this); } void DeclarativeWidget::dataAppend(QObject *object) { - DeclarativeWidget *widget = dynamic_cast(object); - DeclarativeHBoxLayout *hboxLayout = dynamic_cast(object); - DeclarativeVBoxLayout *vboxLayout = dynamic_cast(object); - - if (widget) { - if (m_widget->layout()) { - qmlInfo(this) << "Can not add Widget since a Layout is set already"; + AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) { + if (m_proxiedObject->layout()) { + qmlInfo(this) << "Can not add Widget since a Layout is set already"; + return; + } + + m_children.append(object); + widget->setParent(m_proxiedObject); return; } - m_children.append(object); - qobject_cast(widget->object())->setParent(m_widget); - } else if (hboxLayout) { - // TODO: error when widget is set - - m_children.append(object); - m_widget->setLayout(qobject_cast(hboxLayout->object())); - } else if (vboxLayout) { - // TODO: error when widget is set + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) { + // TODO: error when widget is set - m_children.append(object); - m_widget->setLayout(qobject_cast(vboxLayout->object())); - } else { - m_children.append(object); + m_children.append(object); + m_proxiedObject->setLayout(layout); + return; + } } -} - -int DeclarativeWidget::dataCount() -{ - return m_children.count(); -} - -QObject *DeclarativeWidget::dataAt(int index) -{ - return m_children.at(index); -} -void DeclarativeWidget::dataClear() -{ - qDeleteAll(m_children); - m_children.clear(); + DeclarativeObjectProxy::dataAppend(object); } -CUSTOM_METAOBJECT(DeclarativeWidget, DeclarativeObject, QWidget, m_widget) +CUSTOM_METAOBJECT(DeclarativeWidget, QWidget, m_proxiedObject) // DeclarativeLabel -DeclarativeLabel::DeclarativeLabel(QObject *parent) - : DeclarativeWidget(parent) - , m_label(new QLabel) -{ - connectAllSignals(m_label, this); -} - -DeclarativeLabel::~DeclarativeLabel() +DeclarativeLabel::DeclarativeLabel(QObject *parent) : DeclarativeObjectProxy(parent) { - delete m_label; + connectAllSignals(m_proxiedObject, this); } -QObject* DeclarativeLabel::object() -{ - return m_label; -} - -CUSTOM_METAOBJECT(DeclarativeLabel, DeclarativeWidget, QLabel, m_label) +CUSTOM_METAOBJECT(DeclarativeLabel, QLabel, m_proxiedObject) // DeclarativeTabWidget -DeclarativeTabWidget::DeclarativeTabWidget(QObject *parent) - : DeclarativeWidget(parent) - , m_tabWidget(new QTabWidget) -{ - connectAllSignals(m_tabWidget, this); -} - -DeclarativeTabWidget::~DeclarativeTabWidget() -{ - delete m_tabWidget; -} - -QObject* DeclarativeTabWidget::object() +DeclarativeTabWidget::DeclarativeTabWidget(QObject *parent) : DeclarativeObjectProxy(parent) { - return m_tabWidget; + connectAllSignals(m_proxiedObject, this); } void DeclarativeTabWidget::dataAppend(QObject *object) { - DeclarativeWidget *widget = dynamic_cast(object); - - if (widget) { - // TODO: error when layout is set - m_children.append(object); - m_tabWidget->addTab(qobject_cast(widget->object()), "MyTab"); - } else { - // TODO: error unknown type - } -} + AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); -int DeclarativeTabWidget::dataCount() -{ - return m_children.count(); -} + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) { + // TODO: error when layout is set + m_children.append(object); + m_proxiedObject->addTab(widget, "MyTab"); + return; + } -QObject *DeclarativeTabWidget::dataAt(int index) -{ - return m_children.at(index); -} + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) { + qmlInfo(this) << "Can not add QLayout to QTabWidget"; + return; + } + } -void DeclarativeTabWidget::dataClear() -{ - qDeleteAll(m_children); - m_children.clear(); + DeclarativeObjectProxy::dataAppend(object); } -CUSTOM_METAOBJECT(DeclarativeTabWidget, DeclarativeWidget, QTabWidget, m_tabWidget) +CUSTOM_METAOBJECT(DeclarativeTabWidget, QTabWidget, m_proxiedObject) // DeclarativePushButton -DeclarativePushButton::DeclarativePushButton(QObject *parent) - : DeclarativeWidget(parent) - , m_pushButton(new QPushButton) -{ - connectAllSignals(m_pushButton, this); -} - -DeclarativePushButton::~DeclarativePushButton() +DeclarativePushButton::DeclarativePushButton(QObject *parent) : DeclarativeObjectProxy(parent) { - delete m_pushButton; + connectAllSignals(m_proxiedObject, this); } -QObject* DeclarativePushButton::object() -{ - return m_pushButton; -} - -CUSTOM_METAOBJECT(DeclarativePushButton, DeclarativeWidget, QPushButton, m_pushButton) +CUSTOM_METAOBJECT(DeclarativePushButton, QPushButton, m_proxiedObject) // DeclarativeCheckBox -DeclarativeCheckBox::DeclarativeCheckBox(QObject *parent) - : DeclarativeWidget(parent) - , m_checkBox(new QCheckBox) -{ - connectAllSignals(m_checkBox, this); -} - -DeclarativeCheckBox::~DeclarativeCheckBox() +DeclarativeCheckBox::DeclarativeCheckBox(QObject *parent) : DeclarativeObjectProxy(parent) { - delete m_checkBox; + connectAllSignals(m_proxiedObject, this); } -QObject* DeclarativeCheckBox::object() -{ - return m_checkBox; -} - -CUSTOM_METAOBJECT(DeclarativeCheckBox, DeclarativeWidget, QCheckBox, m_checkBox) +CUSTOM_METAOBJECT(DeclarativeCheckBox, QCheckBox, m_proxiedObject) // DeclarativeSlider -DeclarativeSlider::DeclarativeSlider(QObject *parent) - : DeclarativeWidget(parent) - , m_slider(new QSlider) -{ - m_slider->setOrientation(Qt::Horizontal); - connectAllSignals(m_slider, this); -} - -DeclarativeSlider::~DeclarativeSlider() -{ - delete m_slider; -} - -QObject* DeclarativeSlider::object() +DeclarativeSlider::DeclarativeSlider(QObject *parent) : DeclarativeObjectProxy(parent) { - return m_slider; + connectAllSignals(m_proxiedObject, this); } -CUSTOM_METAOBJECT(DeclarativeSlider, DeclarativeWidget, QSlider, m_slider) +CUSTOM_METAOBJECT(DeclarativeSlider, QSlider, m_proxiedObject) diff --git a/declarativeobjects_p.h b/declarativeobjects_p.h index 78158d8..0defd47 100644 --- a/declarativeobjects_p.h +++ b/declarativeobjects_p.h @@ -24,7 +24,7 @@ virtual int qt_metacall(QMetaObject::Call, int, void **); \ private: \ -class DeclarativeObject : public QObject +class AbstractDeclarativeObject : public QObject { Q_OBJECT @@ -33,15 +33,15 @@ class DeclarativeObject : public QObject Q_CLASSINFO("DefaultProperty", "data") public: - DeclarativeObject(QObject *parent = 0); - virtual ~DeclarativeObject(); + AbstractDeclarativeObject(QObject *parent = 0); + virtual ~AbstractDeclarativeObject(); - virtual QObject* object() = 0; + virtual QObject* object() const = 0; protected: virtual void dataAppend(QObject *); - virtual int dataCount(); - virtual QObject *dataAt(int); + virtual int dataCount() const; + virtual QObject *dataAt(int) const; virtual void dataClear(); private: @@ -53,98 +53,109 @@ class DeclarativeObject : public QObject static void data_clear(QDeclarativeListProperty *); }; -class DeclarativeHBoxLayout : public DeclarativeObject +template +class DeclarativeObjectProxy : public AbstractDeclarativeObject { - DECLARATIVE_OBJECT - public: - DeclarativeHBoxLayout(QObject *parent = 0); - ~DeclarativeHBoxLayout(); + DeclarativeObjectProxy(QObject *parent = 0) : AbstractDeclarativeObject(parent), m_proxiedObject(new T) {} - virtual QObject* object(); + ~DeclarativeObjectProxy() { delete m_proxiedObject; } - virtual void dataAppend(QObject *); - virtual int dataCount(); - virtual QObject *dataAt(int); - virtual void dataClear(); + virtual QObject *object() const { return m_proxiedObject.data(); } - private: - QPointer m_layout; + protected: + virtual void dataAppend(QObject *object) + { + m_children.append(object); + } + + virtual int dataCount() const { return m_children.count(); } + virtual QObject *dataAt(int index) const { return m_children.at(index); } + virtual void dataClear() + { + qDeleteAll(m_children); + m_children.clear(); + } + + protected: + QPointer m_proxiedObject; QVector m_children; }; -class DeclarativeVBoxLayout : public DeclarativeObject +template +class DeclarativeBoxLayout : public DeclarativeObjectProxy +{ + public: + DeclarativeBoxLayout(QObject *parent = 0) : DeclarativeObjectProxy(parent) {} + + protected: + virtual void dataAppend(QObject *object) + { + AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) { + DeclarativeObjectProxy::m_children.append(object); + DeclarativeObjectProxy::m_proxiedObject->addWidget(widget); + return; + } + + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) { + DeclarativeObjectProxy::m_children.append(object); + DeclarativeObjectProxy::m_proxiedObject->addLayout(layout); + return; + } + } + + DeclarativeObjectProxy::dataAppend(object); + } +}; + +class DeclarativeHBoxLayout : public DeclarativeBoxLayout { DECLARATIVE_OBJECT public: - DeclarativeVBoxLayout(QObject *parent = 0); - ~DeclarativeVBoxLayout(); - - virtual QObject* object(); + DeclarativeHBoxLayout(QObject *parent = 0); +}; - virtual void dataAppend(QObject *); - virtual int dataCount(); - virtual QObject *dataAt(int); - virtual void dataClear(); +class DeclarativeVBoxLayout : public DeclarativeBoxLayout +{ + DECLARATIVE_OBJECT - private: - QPointer m_layout; - QVector m_children; + public: + DeclarativeVBoxLayout(QObject *parent = 0); }; -class DeclarativeWidget : public DeclarativeObject +class DeclarativeWidget : public DeclarativeObjectProxy { DECLARATIVE_OBJECT public: DeclarativeWidget(QObject *parent = 0); - ~DeclarativeWidget(); - virtual QObject* object(); - - private: + protected: virtual void dataAppend(QObject *); - virtual int dataCount(); - virtual QObject *dataAt(int); - virtual void dataClear(); - - QPointer m_widget; - QVector m_children; }; -class DeclarativeLabel : public DeclarativeWidget +class DeclarativeLabel : public DeclarativeObjectProxy { DECLARATIVE_OBJECT public: DeclarativeLabel(QObject *parent = 0); - ~DeclarativeLabel(); - - virtual QObject* object(); - - private: - QPointer m_label; }; -class DeclarativeTabWidget : public DeclarativeWidget +class DeclarativeTabWidget : public DeclarativeObjectProxy { DECLARATIVE_OBJECT public: DeclarativeTabWidget(QObject *parent = 0); - ~DeclarativeTabWidget(); - virtual QObject* object(); - - private: + protected: virtual void dataAppend(QObject *); - virtual int dataCount(); - virtual QObject *dataAt(int); - virtual void dataClear(); - - QPointer m_tabWidget; - QVector m_children; }; /* class DeclarativeTab : public DeclarativeWidget @@ -166,46 +177,28 @@ class DeclarativeTab : public DeclarativeWidget QObject* m_child; }; */ -class DeclarativePushButton : public DeclarativeWidget +class DeclarativePushButton : public DeclarativeObjectProxy { DECLARATIVE_OBJECT public: DeclarativePushButton(QObject *parent = 0); - ~DeclarativePushButton(); - - virtual QObject* object(); - - private: - QPointer m_pushButton; }; -class DeclarativeCheckBox : public DeclarativeWidget +class DeclarativeCheckBox : public DeclarativeObjectProxy { DECLARATIVE_OBJECT public: DeclarativeCheckBox(QObject *parent = 0); - ~DeclarativeCheckBox(); - - virtual QObject* object(); - - private: - QPointer m_checkBox; }; -class DeclarativeSlider : public DeclarativeWidget +class DeclarativeSlider : public DeclarativeObjectProxy { DECLARATIVE_OBJECT public: DeclarativeSlider(QObject *parent = 0); - ~DeclarativeSlider(); - - virtual QObject* object(); - - private: - QPointer m_slider; }; #endif diff --git a/declarativewidgetdocument.cpp b/declarativewidgetdocument.cpp index 98f7979..0b7e218 100644 --- a/declarativewidgetdocument.cpp +++ b/declarativewidgetdocument.cpp @@ -68,10 +68,10 @@ QWidget* DeclarativeWidgetDocument::createWidget() return 0; } - DeclarativeObject *declarativeObject = dynamic_cast(object); + AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); if (!declarativeObject) { - qWarning("Root element is no DeclarativeObject subclass"); + qWarning("Root element is no AbstractDeclarativeObject subclass"); return 0; }