Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMetaType::metaObjectForType

QMetaType::metaObjectForType

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GrahamL
    wrote on last edited by
    #1

    Hi I am trying to use QMetaType::metaObjectForType but am always getting a NULL return value and would be grateful if someone could explain why -

    Class declaration
    @
    class Widget : public QWidget
    {
    Q_OBJECT

    public:
    Q_INVOKABLE Widget(QWidget *parent=0);
    Widget(const Widget& other);
    ~Widget();
    };

    Q_DECLARE_METATYPE(Widget)
    @

    Class definition
    @
    const int WidgetTypeID = qRegisterMetaType<Widget>("Widget");

    Widget::Widget(QWidget *parent)
    : QWidget(parent)
    {
    }

    Widget::~Widget()
    {
    }

    Widget::Widget(const Widget& other)
    {
    Q_UNUSED(other)
    }
    @

    Usage
    @
    int id = QMetaType::type("Widget");
    const QMetaObject* baseMetaObject = QMetaType::metaObjectForType(id); -- Returns NULL

        QObject* o = (QObject*)(QMetaType::create(QMetaType::type("Widget"))); -- this works
    

    @

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Solved at http://lists.qt-project.org/pipermail/interest/2014-February/011248.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved