Displaying my JSON data in table view
-
Well this is my JSON data
"Village Name: A B HALLI</br>Ryot Code: INKA010101001001</br>Ryot Name: A M SHANKAREGOWDA</br></br>Village Name: A B HALLI</br>Ryot Code: INKA010101001002</br>Ryot Name: A M SHIVALINGEGOWDA</br></br>Village Name: A B HALLI</br>Ryot Code: INKA010101001003</br>Ryot Name: A P SUNDRA</br></br>Village Name: A B HALLI</br>Ryot Code: INKA010101001004</br>Ryot Name: ALURAIAH M</br>
how do I display it in my TableView with the Headers of Village Name, Ryot Code and Ryot Name.
-
Hi
That does not look like JSON data :)
more like incomplete html. -
@Vineela You should post the real JSON content, not a screen-shot.
What EXACT data do you get from the server?
Regarding reading JSON, start here: http://doc.qt.io/qt-5/qjsondocument.html -
@Vineela Maybe this will help: https://stackoverflow.com/questions/26148188/populate-qtableview-form-json-array
-
-
@Vineela said in Displaying my JSON data in table view:
QJsonTableModel
this is not part of Qt. You can get it from https://github.com/poulh/qjsontablemodel
Or look how it is implemented to get some idea how to do it. -
@jsulm
I've added this one in my .h filepublic: typedef QMap<QString,QString> Heading; typedef QVector<Heading> Header; QJsonTableModel( const Header& header, QObject * parent = 0); bool setJson( const QJsonDocument& json ); bool setJson( const QJsonArray& array ); private: Header m_header; QJsonArray m_json;
and this one in my .cpp file
MainWindow::QJsonTableModel( const QJsonTableModel::Header& header ) : m_header( header ) { }
i got this error
error: ISO C++ forbids declaration of 'QJsonTableModel' with no type [-fpermissive]
QJsonTableModel( const Header& header, QObject * parent = 0); -
@Vineela There is some information how to use it in your code: https://github.com/poulh/qjsontablemodel/blob/master/README.md