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. When reading QJsonArray it gives always 0

When reading QJsonArray it gives always 0

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5qjsonarrayreading
25 Posts 7 Posters 4.2k Views
  • 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.
  • C Offline
    C Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on 12 Feb 2021, 11:47 last edited by
    #21

    Or use a proper QDoubleSpinbox

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pl45m4
      wrote on 12 Feb 2021, 11:55 last edited by
      #22

      Or a QLineEdit with an input mask, so you can be sure that is input of this widget gonna be a number. Then you can write it as double to your Json.

      https://doc.qt.io/qt-5/qlineedit.html#inputMask-prop


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • D deleted286
        12 Feb 2021, 11:05

        @JonB ı didnt get my json from anywhere. I create it by myself

        J Offline
        J Offline
        JonB
        wrote on 12 Feb 2021, 12:03 last edited by
        #23

        @suslucoder said in When reading QJsonArray it gives always 0:

        ı didnt get my json from anywhere. I create it by myself

        So this is not a widget issue, at least at this stage. It's a question of OP deciding on a type to be used in the JSON.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 13 Feb 2021, 07:45 last edited by
          #24

          Exactly. You should format the data properly when you save it. Then the whole problem will just go away and a plain toDouble() will work when reading the file.

          (Z(:^

          D 1 Reply Last reply 15 Feb 2021, 06:11
          0
          • S sierdzio
            13 Feb 2021, 07:45

            Exactly. You should format the data properly when you save it. Then the whole problem will just go away and a plain toDouble() will work when reading the file.

            D Offline
            D Offline
            deleted286
            wrote on 15 Feb 2021, 06:11 last edited by
            #25

            Thanks for all answers. I will reformat my json file and try it again

            1 Reply Last reply
            0

            21/25

            12 Feb 2021, 11:47

            • Login

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