This more or less what Qt do with ui which xml file convert to .h. What I'm trying to do is get List from Json file
_____________JsonFile_____________
Qt Code:
  1. {
  2. "common_message": {
  3. "Id_message": "NA"
  4. "Lenght" : "NA",
  5. "bit" : "NA",[B][/B]
  6. etc
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 
_________________________________

I want to display Id_message in qstring and the rest of the field

___________________main.cpp______________

Qt Code:
  1. QString filename = QFileDialog::getOpenFileName(
  2.  
  3. this,
  4.  
  5. tr("Charger les resources HW"),
  6.  
  7. "C//workspace_llb_27-05-2016/10_Terminal_Generic/configuration",
  8.  
  9. "json document (*.json)"
  10.  
  11. );
  12.  
  13. QFile file(filename);
  14.  
  15. QString in;
  16.  
  17.  
  18.  
  19. if (!file.open(QIODevice::ReadWrite))
  20.  
  21. {
  22.  
  23. QMessageBox::information(0,"info",file.errorString());
  24.  
  25. return;
  26.  
  27. }
  28.  
  29. in = file.readAll();
  30.  
  31. file.close();
  32.  
  33. // qWarning() << in;
  34.  
  35. m_configHw = QJsonDocument::fromJson(in.toUtf8());
  36.  
  37. buildDock();
  38.  
  39. }
  40.  
  41.  
  42.  
  43. // TODO
  44. void MainWindow::buildDock()
  45.  
  46. {
  47.  
  48. QDockWidget *dock = new QDockWidget("test",this);
  49.  
  50. dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
  51.  
  52.  
  53.  
  54. QJsonObject jsonObject = m_configHw.object();
  55.  
  56.  
  57.  
  58. // QStringList list = jsonObject.keys();
  59.  
  60. // QVariantList list = jsonArray.toVariantList();
  61.  
  62. // QJsonArray jsonArray = jsonObject.value("common_message").toArray();
  63.  
  64. // QStringList list = jsonObject.value("common_message").toString();
  65.  
  66. QJsonArray jsonArray = jsonObject.value("common_message").toArray();
  67.  
  68.  
  69.  
  70. QVariantList list = jsonArray.toVariantList();
  71.  
  72. // for(int i(0); i< jsonArray.size(), i++){
  73.  
  74. // QJsonObject obj = jsonArray[i].toObject();
  75.  
  76. // list.append(obj.);
  77.  
  78. // }
  79.  
  80.  
  81.  
  82. // foreach(const QJsonValue & value, jsonArray){
  83.  
  84. // QJsonObject obj = value.toObject();
  85.  
  86. // list = obj.keys();
  87.  
  88. // }
  89.  
  90. foreach(const QVariant & value, jsonArray){
  91.  
  92. QVariantMap obj = value.toMap();
  93.  
  94. qDebug() << obj.value("Id_message");
  95.  
  96. }
  97.  
  98.  
  99.  
  100.  
  101.  
  102. // QVariantMap pair = jsonObject.toVariantMap();
  103.  
  104.  
  105.  
  106. // QAbstractItemModel *model = new QStringListModel(list.toStdList());
  107.  
  108. // QListView *view = new QListView;
  109.  
  110. // view->setModel(model);
  111.  
  112.  
  113.  
  114. // ui->dockWidgetContents->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
  115.  
  116. // dock->setWidget(view);
  117.  
  118. addDockWidget(Qt::LeftDockWidgetArea, dock);
  119. }
To copy to clipboard, switch view to plain text mode 

Sorry It's a lot messy but my aim is to display a list of json and a least in my IHM change the values in time. how could I do a list from the field in my json ?
If you don't get it what I'm trying to do ask me question !
Thanks for any advice