Important: Please read the Qt Code of Conduct -

QML : Error: Unknown method return type: QList<QStringList>

  • Hello, I have a function in Qt that returns QList<QStringList> object and I'm using it in a QML file. The compilation is fine. However, when executing it the QML throws this error : Unknown method return type: QList<QStringList>. Please help.

  • Moderators

    You need to register this type using Q_DECLARE_METATYPE. Also you'll probably need to use qRegisterType(), but I'm not sure. Look it up in the documentation.

  • Thank you for the reply. I tried different things but no success. Can you please give me an example?

  • @Iheb hi
    you can return a QVariant instead of QList<QStringList>

       Q_INVOKABLE QVariant getlistOfLists(){
            QList<QStringList> listOfLists;
            QStringList l1;
            QStringList l2;
            QStringList l3;
            QStringList l4;
            return  QVariant::fromValue(listOfLists);
      Component.onCompleted: {
            var listsList = testObj.getlistOfLists()
            for(var i in listsList){

Log in to reply