How to download or keep json from the file to QTable (Qt) table?



  • Got a file. trip.jsonFor example

    {
        "name": "Hawai",
        "days": 25
    }
    

    How can this file download/ store information in/from the table QTableView?



  • QTableView You can set for display. QAbstractItemModel(or her heir, in your case, fits-- QStandardItemModelSo you need to create your model, the heir of one of these classes, to fill it out. .json The file, and display it in the table by void QTableView::setModel(QAbstractItemModel * model).

    That is, both in the laboratory and usually in Qt, the logic of completing the model will be in a separate class.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2