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. How can I create our configuration file?

How can I create our configuration file?

Scheduled Pinned Locked Moved Unsolved General and Desktop
config fileqt5json
19 Posts 3 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.
  • D Offline
    D Offline
    deleted286
    wrote on 22 Jan 2021, 13:07 last edited by
    #1

    Hi everyone. I want to create a configuration file for my own app. For storing everything there and do some operations with it. What is the best way for doing it?

    What should i use for doing such a thing? JSON or XML or anything else?
    Does QT support such thing?

    Thank you

    J 1 Reply Last reply 22 Jan 2021, 13:13
    0
    • D deleted286
      22 Jan 2021, 13:07

      Hi everyone. I want to create a configuration file for my own app. For storing everything there and do some operations with it. What is the best way for doing it?

      What should i use for doing such a thing? JSON or XML or anything else?
      Does QT support such thing?

      Thank you

      J Offline
      J Offline
      JonB
      wrote on 22 Jan 2021, 13:13 last edited by JonB
      #2

      @suslucoder
      You can indeed. Most things these days use JSON.

      But before you write your own configuration file, at least read Qt's QSettings and see whether that would serve you sufficiently. It saves you doing a lot of work, and handles the configuration file location/writing/reading for you. If you need to, you can even make any of the key/values store a JSON string (suitably encoded) for the value, if it's especially complex. However, if your JSON configuration settings are large it may not be ideal.

      D 1 Reply Last reply 22 Jan 2021, 13:21
      0
      • J JonB
        22 Jan 2021, 13:13

        @suslucoder
        You can indeed. Most things these days use JSON.

        But before you write your own configuration file, at least read Qt's QSettings and see whether that would serve you sufficiently. It saves you doing a lot of work, and handles the configuration file location/writing/reading for you. If you need to, you can even make any of the key/values store a JSON string (suitably encoded) for the value, if it's especially complex. However, if your JSON configuration settings are large it may not be ideal.

        D Offline
        D Offline
        deleted286
        wrote on 22 Jan 2021, 13:21 last edited by
        #3

        @JonB Thank you for answer. Is there any resource you can suggest me for creating config file with JSON?

        J 1 Reply Last reply 22 Jan 2021, 13:23
        0
        • D deleted286
          22 Jan 2021, 13:21

          @JonB Thank you for answer. Is there any resource you can suggest me for creating config file with JSON?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 22 Jan 2021, 13:23 last edited by
          #4

          @suslucoder https://doc.qt.io/qt-5/json.html

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

          D 2 Replies Last reply 22 Jan 2021, 13:39
          0
          • J jsulm
            22 Jan 2021, 13:23

            @suslucoder https://doc.qt.io/qt-5/json.html

            D Offline
            D Offline
            deleted286
            wrote on 22 Jan 2021, 13:39 last edited by
            #5

            @jsulm Thank you.

            1 Reply Last reply
            0
            • J jsulm
              22 Jan 2021, 13:23

              @suslucoder https://doc.qt.io/qt-5/json.html

              D Offline
              D Offline
              deleted286
              wrote on 25 Jan 2021, 07:14 last edited by
              #6

              @jsulm Hi. Is there any way to convert my classes into json file?
              How can i write all of them as a JSON file, i did not understand actually

              J 1 Reply Last reply 25 Jan 2021, 07:22
              0
              • D deleted286
                25 Jan 2021, 07:14

                @jsulm Hi. Is there any way to convert my classes into json file?
                How can i write all of them as a JSON file, i did not understand actually

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 25 Jan 2021, 07:22 last edited by
                #7

                @suslucoder said in How can I create our configuration file?:

                How can i write all of them as a JSON file

                This is your job. There is no generic way.
                In the link I gave you before there is a link to an example - did you check it?
                https://doc.qt.io/qt-5/qtcore-serialization-savegame-example.html

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

                D 1 Reply Last reply 25 Jan 2021, 07:27
                0
                • J jsulm
                  25 Jan 2021, 07:22

                  @suslucoder said in How can I create our configuration file?:

                  How can i write all of them as a JSON file

                  This is your job. There is no generic way.
                  In the link I gave you before there is a link to an example - did you check it?
                  https://doc.qt.io/qt-5/qtcore-serialization-savegame-example.html

                  D Offline
                  D Offline
                  deleted286
                  wrote on 25 Jan 2021, 07:27 last edited by
                  #8

                  @jsulm yes I've. I want to ask one question too. Can i read data which are coming from usb, that is created as a config file with JSON

                  J 1 Reply Last reply 25 Jan 2021, 07:29
                  0
                  • D deleted286
                    25 Jan 2021, 07:27

                    @jsulm yes I've. I want to ask one question too. Can i read data which are coming from usb, that is created as a config file with JSON

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 25 Jan 2021, 07:29 last edited by
                    #9

                    @suslucoder said in How can I create our configuration file?:

                    Can i read data which are coming from usb

                    In what way "coming from usb"? Do you mean you have a disk connected via USB containing a JSON file? If so, then sure, why not?

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

                    D 1 Reply Last reply 25 Jan 2021, 07:32
                    0
                    • J jsulm
                      25 Jan 2021, 07:29

                      @suslucoder said in How can I create our configuration file?:

                      Can i read data which are coming from usb

                      In what way "coming from usb"? Do you mean you have a disk connected via USB containing a JSON file? If so, then sure, why not?

                      D Offline
                      D Offline
                      deleted286
                      wrote on 25 Jan 2021, 07:32 last edited by deleted286
                      #10

                      @jsulm Nope.
                      I want to read some daha and chart it. The datas comes me via some USB ports.(I hope I can explain properly)
                      I thought that, doing it with a config file might make more sense. And for doing it, i should create my own config file, using JSON. Right?

                      J 1 Reply Last reply 25 Jan 2021, 07:35
                      0
                      • D deleted286
                        25 Jan 2021, 07:32

                        @jsulm Nope.
                        I want to read some daha and chart it. The datas comes me via some USB ports.(I hope I can explain properly)
                        I thought that, doing it with a config file might make more sense. And for doing it, i should create my own config file, using JSON. Right?

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 25 Jan 2021, 07:35 last edited by
                        #11

                        @suslucoder Sorry, I don't understand. Do you read some data from some device connected via USB? If so - what device is that and what does it actually send? And what does your config file have to do with that USB device? Please explain clearly your use case.

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

                        D 1 Reply Last reply 25 Jan 2021, 07:37
                        0
                        • J jsulm
                          25 Jan 2021, 07:35

                          @suslucoder Sorry, I don't understand. Do you read some data from some device connected via USB? If so - what device is that and what does it actually send? And what does your config file have to do with that USB device? Please explain clearly your use case.

                          D Offline
                          D Offline
                          deleted286
                          wrote on 25 Jan 2021, 07:37 last edited by
                          #12

                          @jsulm it is GPS. I will get some daha from GPS. I read them and add into a chart. I want to read operation with a config file. Is it silly to do it this way?

                          J 1 Reply Last reply 25 Jan 2021, 07:41
                          0
                          • D deleted286
                            25 Jan 2021, 07:37

                            @jsulm it is GPS. I will get some daha from GPS. I read them and add into a chart. I want to read operation with a config file. Is it silly to do it this way?

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 25 Jan 2021, 07:41 last edited by
                            #13

                            @suslucoder said in How can I create our configuration file?:

                            I want to read operation with a config file

                            What does this mean? What is "operation"?

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

                            D 1 Reply Last reply 25 Jan 2021, 07:44
                            0
                            • J jsulm
                              25 Jan 2021, 07:41

                              @suslucoder said in How can I create our configuration file?:

                              I want to read operation with a config file

                              What does this mean? What is "operation"?

                              D Offline
                              D Offline
                              deleted286
                              wrote on 25 Jan 2021, 07:44 last edited by
                              #14

                              @jsulm it is reading

                              J 1 Reply Last reply 25 Jan 2021, 07:49
                              0
                              • D deleted286
                                25 Jan 2021, 07:44

                                @jsulm it is reading

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 25 Jan 2021, 07:49 last edited by
                                #15

                                @suslucoder Sorry, I still fail to understand you.
                                "I want to read operation with a config file" - please explain clearly what you mean here.
                                This is your post from before:
                                "I want to read some daha and chart it. The datas comes me via some USB ports.(I hope I can explain properly)
                                I thought that, doing it with a config file might make more sense."
                                So, you read data from USB and want to do it via a config file - this does not make sense to me, sorry. Can you previde an example of the config file, that could help to understand what you want to do.

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

                                D 1 Reply Last reply 25 Jan 2021, 07:52
                                1
                                • J jsulm
                                  25 Jan 2021, 07:49

                                  @suslucoder Sorry, I still fail to understand you.
                                  "I want to read operation with a config file" - please explain clearly what you mean here.
                                  This is your post from before:
                                  "I want to read some daha and chart it. The datas comes me via some USB ports.(I hope I can explain properly)
                                  I thought that, doing it with a config file might make more sense."
                                  So, you read data from USB and want to do it via a config file - this does not make sense to me, sorry. Can you previde an example of the config file, that could help to understand what you want to do.

                                  D Offline
                                  D Offline
                                  deleted286
                                  wrote on 25 Jan 2021, 07:52 last edited by
                                  #16

                                  @jsulm said in

                                  So, you read data from USB and want to do it via a config file - this does not make sense to me, sorry.

                                  Im asking it. In which case can i use config file?

                                  J J 2 Replies Last reply 25 Jan 2021, 08:25
                                  0
                                  • D deleted286
                                    25 Jan 2021, 07:52

                                    @jsulm said in

                                    So, you read data from USB and want to do it via a config file - this does not make sense to me, sorry.

                                    Im asking it. In which case can i use config file?

                                    J Offline
                                    J Offline
                                    JonB
                                    wrote on 25 Jan 2021, 08:25 last edited by JonB
                                    #17

                                    @suslucoder
                                    As @jsulm has said, nobody understands what you are saying/asking.

                                    In any case, you read whatever from USB. That data either is or is not in JSON or in config file format or whatever. And that's what you have to work with. The fact of USB or not is neither here nor there. It's just a stream of data/file.

                                    1 Reply Last reply
                                    2
                                    • D deleted286
                                      25 Jan 2021, 07:52

                                      @jsulm said in

                                      So, you read data from USB and want to do it via a config file - this does not make sense to me, sorry.

                                      Im asking it. In which case can i use config file?

                                      J Offline
                                      J Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on 25 Jan 2021, 08:31 last edited by
                                      #18

                                      @suslucoder said in How can I create our configuration file?:

                                      In which case can i use config file?

                                      In case you have or need a config file of course! Sorry I really don't understand what you are asking...

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

                                      D 1 Reply Last reply 25 Jan 2021, 08:42
                                      1
                                      • J jsulm
                                        25 Jan 2021, 08:31

                                        @suslucoder said in How can I create our configuration file?:

                                        In which case can i use config file?

                                        In case you have or need a config file of course! Sorry I really don't understand what you are asking...

                                        D Offline
                                        D Offline
                                        deleted286
                                        wrote on 25 Jan 2021, 08:42 last edited by
                                        #19

                                        @jsulm Ok. Thank you for your answers.

                                        1 Reply Last reply
                                        0

                                        1/19

                                        22 Jan 2021, 13:07

                                        • Login

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