Displaying my JSON data in table view
-
wrote on 4 Feb 2019, 10:08 last edited by
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.
Lifetime Qt Championwrote on 4 Feb 2019, 12:36 last edited by jsulm 2 Apr 2019, 12:37@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.htmlwrote on 5 Feb 2019, 05:35 last edited by@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 I can remember that you already asked how to parse JSON. So, what is the problem now? Is it parsing JSON or putting the data into table?
-
@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
-
@Vineela If you get an error you should post the error here
-
wrote on 5 Feb 2019, 08:27 last edited by
-
@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.Lifetime Qt Championwrote on 5 Feb 2019, 08:44 last edited by jsulm 2 May 2019, 09:28@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.wrote on 6 Feb 2019, 08:52 last edited by@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);Lifetime Qt Championwrote on 6 Feb 2019, 08:55 last edited by jsulm 2 Jun 2019, 08:57@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 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
6/17