Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-79699

Wrong showing array in QML console log

    XMLWordPrintable

Details

    • macOS

    Description

      When I am trying to dump (console.log) array that is came to JS from C++ I see flattening array even if there array inside of array, but when I am doing "foreach" it's OK.

      JS:

      console.log("list:",CPPDeclaredObject.mList());
      var oList = CPPDeclaredObject.mList();
      for (var i = 0; i < oList.length; i++) {
      	console.log("line",i,":",oList[i]);
      }
      

      C++

      QList<QVariant> CPPDeclaredObject::mList(void) {
      
      	QList<QVariant> oOutput = {};
      	int iCounter = 0;
      
      	for (
      		QHash<QString,CPPDeclaredObjectPrimitive*>::iterator i = pObjects.begin();
      		i != pObjects.end();
      		++i
      	) {
      		QList<QVariant> iObject = {};
      		iObject.append(i.value()->pName);
      		iObject.append(i.value()->pDescription);
      		oOutput.insert(iCounter,iObject);
      		++iCounter;
      	}
      
      	return oOutput;
      }
      

      Console output from JS console.log():

      qml: list: [test 1 name,test 111111 description,test 2 name,test 22222222222222 description,QML_name2,QML_description,QML_name1,QML_description]
      qml: line 0 : [test 1 name,test 111111 description]
      qml: line 1 : [test 2 name,test 22222222222222 description]
      qml: line 2 : [QML_name2,QML_description]
      qml: line 3 : [QML_name1,QML_description]
      

      Sometimes it's making debug very complicated.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            bogong Alexandr KIRILOV
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes