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. 'qt_metatype_id' is not a member of...
Forum Updated to NodeBB v4.3 + New Features

'qt_metatype_id' is not a member of...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 12.6k 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.
  • T Offline
    T Offline
    Tjsail33
    wrote on last edited by
    #1

    I have a pretty straightforward question. i am getting the error @/usr/include/qt4/QtCore/qmetatype.h:169: error: ‘qt_metatype_id’ is not a member of ‘QMetaTypeId<QList<MOCourse*> >’@ when I attempt to execute the following code. Anyone have any ideas?

    Here is the code that triggers the issue...
    @
    QDeclarativeView *view = w->getDeclarativeView();
    QDeclarativeContext *ctxt = view->rootContext();
    //line with the error
    ctxt->setContextProperty("course100Model", QVariant::fromValue(courseList));
    @

    And here is the header for MOCourse, where you can see that I have declared the metatype for the pointer at the bottom.
    @

    #ifndef MOCOURSE_H
    #define MOCOURSE_H

    #include <QString>
    #include <vector>
    #include <QObject>
    #include <QMetaType>

    using namespace std;

    class MOCourse : public QObject
    {
    Q_OBJECT

    Q_PROPERTY(QString name READ name WRITE setName)
    Q_PROPERTY(QString number READ number WRITE setNumber)
    Q_PROPERTY(QString image READ image WRITE setImage)
    Q_PROPERTY(QString desc READ desc WRITE setDesc)
    

    public:
    // Default constructor
    MOCourse();
    MOCourse(QString n, QString num, QString pic, QString d);
    // Whether the course object was modified during the course of execution
    bool modified;
    // Row in database table
    int ID;
    // Course level
    int level;
    // Full description of course
    QString description;
    // File path of this course's large picture
    QString picture;
    // File path of this course's iconic picture
    QString icon;
    // Course title (ex. CS205 Software Engineering)
    QString courseNumber;
    QString courseTitle;
    // Vector of IDs linking to relevant demos
    vector<int> demoIDs;
    // Vector of text blurbs from opinions
    QString opinions;
    // Vector of text blurbs from interviews
    // TODO: replace with interview object
    QString interviews;

    QString name() const;
    QString number() const;
    QString image() const;
    QString desc() const;
    

    public slots:
    void setName(QString s);
    void setNumber(QString s);
    void setImage(QString s);
    void setDesc(QString s);

    };
    Q_DECLARE_METATYPE(MOCourse*)

    #endif // MOCOURSE_H

    @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Be aware that <code>MOCourse*</code> and <code>QList<MOCourse*></code> are two different types. If you want to store the latter one in a QVariant you will have to declare it as meta type as well.
      @
      Q_DECLARE_METATYPE(QList<MOCourse*>)
      @

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tjsail33
        wrote on last edited by
        #3

        Okay, that solved my first problem. Thanks for that Lukas.

        However I am now getting the error @Unable to assign QList<MOCourse*> to QDeclarativeListModel*@ in my QML file. Any idea how to fix this? I did not find any relevant information online.

        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