Here's what I have tried:

Header:
Qt Code:
  1. #include <QQuickItem>
  2. #include <iostream>
  3.  
  4. class Controller : public QObject
  5. {
  6. Q_OBJECT
  7.  
  8. Q_PROPERTY(QList <QVariantList> names READ names WRITE setnames NOTIFY namesChanged)
  9. QList <QVariantList> m_names;
  10.  
  11. public:
  12. Controller()
  13. {
  14. }
  15. ~Controller() {
  16. }
  17.  
  18. QList <QVariantList> names() const
  19. {
  20. return m_names;
  21. }
  22.  
  23. public slots:
  24. void setnames(QList <QVariantList> arg)
  25. {
  26. QVariantList p;
  27. if (arg.size () > 0)
  28. {
  29. p = arg.first ();
  30. std::cout << "\narg: \n" << p[0].toInt ();
  31. }
  32. else
  33. std::cout << "\nqqqq " << arg.size () << "\n";
  34. }
  35.  
  36. signals:
  37. void namesChanged(QList <QVariantList> arg);
  38. };
To copy to clipboard, switch view to plain text mode 

qml

Qt Code:
  1. import QtQuick 2.0
  2. import FromCpp 1.0
  3.  
  4. Rectangle
  5. {
  6. property variant arras: [[1,2,3], [4,5,6]]
  7. Controller
  8. {
  9. id: ppp
  10. }
  11.  
  12. MouseArea
  13. {
  14. anchors.fill: parent
  15. onClicked:
  16. {
  17. ppp.setnames(arras)
  18. console.log(arras.length)
  19. }
  20. }
  21. }
To copy to clipboard, switch view to plain text mode 


The exact output from QtCreator:
Qt Code:
  1. Starting /home/***/documents/test/build-junk-Desktop_Qt_5_1_0_GCC_64bit-Debug/junk...
  2. QML debugging is enabled. Only use this in a safe environment.
  3. 2
  4.  
  5. qqqq 0
  6. QThreadStorage: Thread 0x181e270 exited after QThreadStorage 2 destroyed
  7. /home/***/documents/test/build-junk-Desktop_Qt_5_1_0_GCC_64bit-Debug/junk exited with code 0
To copy to clipboard, switch view to plain text mode 
///

Here, as you can see the size of the 2D array from QML is printed correctly as 2 and the size is printed 0 from c++.

Why is that happening? Please explain.