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
Qt 6.11 is out! See what's new in the release blog

Displaying my JSON data in table view

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 4 Posters 7.2k 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.
  • VineelaV Vineela

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

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on 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
    • VineelaV Vineela

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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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

      VineelaV 1 Reply Last reply
      0
      • jsulmJ jsulm

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

        VineelaV Offline
        VineelaV Offline
        Vineela
        wrote on last edited by Vineela
        #8

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

        jsulmJ 1 Reply Last reply
        0
        • VineelaV Vineela

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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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

          VineelaV 1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on 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

            VineelaV 1 Reply Last reply
            1
            • VRoninV VRonin

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

              VineelaV Offline
              VineelaV Offline
              Vineela
              wrote on 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
              • jsulmJ jsulm

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

                VineelaV Offline
                VineelaV Offline
                Vineela
                wrote on 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.

                jsulmJ 1 Reply Last reply
                0
                • VineelaV Vineela

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

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by jsulm
                  #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

                  VineelaV 1 Reply Last reply
                  3
                  • jsulmJ jsulm

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

                    VineelaV Offline
                    VineelaV Offline
                    Vineela
                    wrote on 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);

                    jsulmJ 1 Reply Last reply
                    0
                    • VineelaV Vineela

                      @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);

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by jsulm
                      #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

                      VineelaV 1 Reply Last reply
                      2
                      • jsulmJ jsulm

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

                        VineelaV Offline
                        VineelaV Offline
                        Vineela
                        wrote on last edited by
                        #16

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

                        jsulmJ 1 Reply Last reply
                        0
                        • VineelaV Vineela

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

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 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

                          • Login

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