Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Displaying my JSON data in table view
Forum Updated to NodeBB v4.3 + New Features

Displaying my JSON data in table view

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 4 Posters 4.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vineela
    wrote on 4 Feb 2019, 10:08 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Feb 2019, 10:16 last edited by
      #2

      Hi
      That does not look like JSON data :)
      more like incomplete html.

      V 1 Reply Last reply 4 Feb 2019, 10:40
      4
      • M mrjj
        4 Feb 2019, 10:16

        Hi
        That does not look like JSON data :)
        more like incomplete html.

        V Offline
        V Offline
        Vineela
        wrote on 4 Feb 2019, 10:40 last edited by
        #3

        @mrjj

        0_1549276719382_jj.png

        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.

        J 1 Reply Last reply 4 Feb 2019, 12:36
        0
        • V Vineela
          4 Feb 2019, 10:40

          @mrjj

          0_1549276719382_jj.png

          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.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 4 Feb 2019, 12:36 last edited by jsulm 2 Apr 2019, 12:37
          #4

          @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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          V 1 Reply Last reply 5 Feb 2019, 05:35
          2
          • J jsulm
            4 Feb 2019, 12:36

            @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

            V Offline
            V Offline
            Vineela
            wrote on 5 Feb 2019, 05:35 last edited by
            #5

            @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.

            J 2 Replies Last reply 5 Feb 2019, 05:39
            0
            • V Vineela
              5 Feb 2019, 05:35

              @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.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 5 Feb 2019, 05:39 last edited by
              #6

              @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?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • V Vineela
                5 Feb 2019, 05:35

                @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.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 5 Feb 2019, 05:42 last edited by
                #7

                @Vineela Maybe this will help: https://stackoverflow.com/questions/26148188/populate-qtableview-form-json-array

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                V 1 Reply Last reply 5 Feb 2019, 06:51
                0
                • J jsulm
                  5 Feb 2019, 05:42

                  @Vineela Maybe this will help: https://stackoverflow.com/questions/26148188/populate-qtableview-form-json-array

                  V Offline
                  V Offline
                  Vineela
                  wrote on 5 Feb 2019, 06:51 last edited by Vineela 2 May 2019, 06:51
                  #8

                  @jsulm thanks but little bit confused with the declaring error thing.

                  J 1 Reply Last reply 5 Feb 2019, 06:51
                  0
                  • V Vineela
                    5 Feb 2019, 06:51

                    @jsulm thanks but little bit confused with the declaring error thing.

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 5 Feb 2019, 06:51 last edited by
                    #9

                    @Vineela If you get an error you should post the error here

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    V 1 Reply Last reply 5 Feb 2019, 08:41
                    0
                    • V Offline
                      V Offline
                      VRonin
                      wrote on 5 Feb 2019, 08:27 last edited by
                      #10

                      https://v-play.net/apps/avoid-cpp-models-qt

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      V 1 Reply Last reply 5 Feb 2019, 08:37
                      1
                      • V VRonin
                        5 Feb 2019, 08:27

                        https://v-play.net/apps/avoid-cpp-models-qt

                        V Offline
                        V Offline
                        Vineela
                        wrote on 5 Feb 2019, 08:37 last edited by
                        #11

                        @VRonin thnks but what about Widget than QML??

                        my only problem is how to display in TableView....

                        1 Reply Last reply
                        0
                        • J jsulm
                          5 Feb 2019, 06:51

                          @Vineela If you get an error you should post the error here

                          V Offline
                          V Offline
                          Vineela
                          wrote on 5 Feb 2019, 08:41 last edited by
                          #12

                          @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.

                          J 1 Reply Last reply 5 Feb 2019, 08:44
                          0
                          • V Vineela
                            5 Feb 2019, 08:41

                            @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.

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 5 Feb 2019, 08:44 last edited by jsulm 2 May 2019, 09:28
                            #13

                            @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.

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            V 1 Reply Last reply 6 Feb 2019, 08:52
                            3
                            • J jsulm
                              5 Feb 2019, 08:44

                              @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.

                              V Offline
                              V Offline
                              Vineela
                              wrote on 6 Feb 2019, 08:52 last edited by
                              #14

                              @jsulm
                              I've added this one in my .h file

                              public:
                               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);

                              J 1 Reply Last reply 6 Feb 2019, 08:55
                              0
                              • V Vineela
                                6 Feb 2019, 08:52

                                @jsulm
                                I've added this one in my .h file

                                public:
                                 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);

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 6 Feb 2019, 08:55 last edited by jsulm 2 Jun 2019, 08:57
                                #15

                                @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.

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                V 1 Reply Last reply 6 Feb 2019, 09:12
                                2
                                • J jsulm
                                  6 Feb 2019, 08:55

                                  @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.

                                  V Offline
                                  V Offline
                                  Vineela
                                  wrote on 6 Feb 2019, 09:12 last edited by
                                  #16

                                  @jsulm well thanks ill try my best now sorry for my mistakes.

                                  J 1 Reply Last reply 6 Feb 2019, 09:21
                                  0
                                  • V Vineela
                                    6 Feb 2019, 09:12

                                    @jsulm well thanks ill try my best now sorry for my mistakes.

                                    J Offline
                                    J Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on 6 Feb 2019, 09:21 last edited by
                                    #17

                                    @Vineela There is some information how to use it in your code: https://github.com/poulh/qjsontablemodel/blob/master/README.md

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    2

                                    7/17

                                    5 Feb 2019, 05:42

                                    • Login

                                    • Login or register to search.
                                    7 out of 17
                                    • First post
                                      7/17
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved