On Monday, February 17, 2014 09:37:00 Graham Labdon wrote: > Hi > > I am trying to use QMetaType::metaObjectForType but it is always returning > NULL > > I have attached my class declaration and would be grateful if anyone can > explain why I am getting a NULL return value > > Many thanks > metatype.txt > metatype.txt > Class.h - > class Widget : public QWidget > { > Q_OBJECT > > public: > Q_INVOKABLE Widget(QWidget *parent=0); > Widget(const Widget& other); > ~Widget(); > }; > > Q_DECLARE_METATYPE(Widget)
Remove this line. > > Class.cpp > const int WidgetTypeID = qRegisterMetaType<Widget>("Widget"); Register the pointer. Don't specify the string: qRegisterMetaType<Widget*>(); Most likely you should move this from global scope to your usage section. > > Usage > int id = QMetaType::type("Widget"); int id = QMetaType::type("Widget*"); Thanks, -- Stephen Kelly <stephen.ke...@kdab.com> | Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090 KDAB - Qt Experts - Platform-Independent Software Solutions
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest