Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. 'Unable to handle unregistered datatype' when trying to use QVector in Repeater

'Unable to handle unregistered datatype' when trying to use QVector in Repeater

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 359 Views
  • 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.
  • snkaupeS Offline
    snkaupeS Offline
    snkaupe
    wrote on last edited by
    #1

    I'm trying to get a list of Channel objects to do something with them in a QML Repeater, but only get the following error message when trying to access the relevant property (actual namespace names replaced):

    QMetaProperty::read: Unable to handle unregistered datatype 'QVector<ns1::ns2::Channel*>' for property 'ns1::ns2::Room::channels'
    

    Now, the types Channel and Room are both registered to the QML engine, as well as a corresponding evocation of qRegisterMetaType for their pointer derivatives:

    qRegisterMetaType<Channel*>("Channel*");
    qRegisterMetaType<Room*>("Room*");
    //...
    qmlRegisterUncreatableType<Channel>("ns", 1, 0, "Channel", "const");
    qmlRegisterUncreatableType<Room>("ns", 1, 0, "Room", "const");
    

    Room and Channel both inherit from QObject (through a number of other types). Room has the property I'm trying to access:

    class Room : public QObject {
      // ...
      Q_PROPERTY(QVector<ns1::ns2::Channel*> channels READ channelReferences NOTIFY channelReferencesChanged)
      // ...
      Q_INVOKABLE QVector<ns1::ns2Channel*>& channelReferences() { return m_channels; }
      // ...
    signals:
      void channelReferencesChanged();
      // ...
    private:
      QVector<Channel*> m_channels;
    }
    

    I then try to access said property from QML:

    Repeater {
        model: parent.controller.room.channels // parent.controller is a different class, its 'room' property returns a Room*
        delegate: RoundButton {
            radius: 5
            text: "foo"
        }
    }
    

    I cannot find anything that is missing in order to use the C++ objects on the QML side. In fact, I'm doing something very similar with a different class and it works quite nicely.

    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