[Interest] QMetaType::metaObjectForType
Stephen Kelly
stephen.kelly at kdab.com
Mon Feb 17 10:41:08 CET 2014
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.kelly at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140217/6ff06784/attachment.sig>
More information about the Interest
mailing list