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. -
well this is my data from URL and which i gave was my qDebug response from URL sorry for my mistake so can i expect my answer plzz.
@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 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 -
@jsulm well ok now i've changed it to JSON data check this link
http://13.232.156.73/CropMgt/Json/farmerList.php?ID=INKA010101
so i need them to display in my tableView format plz help me out.
-
@jsulm well ok now i've changed it to JSON data check this link
http://13.232.156.73/CropMgt/Json/farmerList.php?ID=INKA010101
so i need them to display in my tableView format plz help me out.
@Vineela Maybe this will help: https://stackoverflow.com/questions/26148188/populate-qtableview-form-json-array
-
@Vineela Maybe this will help: https://stackoverflow.com/questions/26148188/populate-qtableview-form-json-array
-
-
@jsulm
error: 'QJsonTableModel' has not been declared
error: 'episodes' was not declared in this scope
I didn't exactly get that code from the link properly (didn't understand) only with the declaring thing.@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. -
@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); -
@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 This is not valid C++ and does not make sense. QJsonTableModel is a class. Download the header file and cpp file from the link I provided and add them to your project.
-
@Vineela There is some information how to use it in your code: https://github.com/poulh/qjsontablemodel/blob/master/README.md