Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. run through each components on the page
Forum Updated to NodeBB v4.3 + New Features

run through each components on the page

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 1.1k Views 2 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.
  • D Offline
    D Offline
    DavidM29
    wrote on last edited by
    #1

    Hello,

    I would like to run through each components of a page. This will be in order to access a parameter of this element and get its state to save in a properties file to save some option.

    This is maybe not a good approach so if anybody know a good way to manage option on a saved file please tell me. It's the first time I have this kind of stuff in C++/QML.
    In Java it is made with ".properties" files. But I did not find any equivalent in C++/QML .

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      If it is only about saving settings, then you can use Settings component.

      If you do indeed want to run through all properties of all objects, do this:

      • get your root QML element in C++
      • loop (recursively) through all children
      • loop through all properties for each child

      A kind-of-but-not-really example for this can be found here https://github.com/sierdzio/closecombatfree/blob/master/src/ccfgamemanager.cpp#L74

      (Z(:^

      1 Reply Last reply
      2
      • D Offline
        D Offline
        DavidM29
        wrote on last edited by
        #3

        I'm taking a look at the Settings component.
        Is it capable to save the settings in separate file wich I could eventually generate with an external app. What it imply is that is as a well know format such as .xml, .json or something like that ?

        sierdzioS 1 Reply Last reply
        0
        • D DavidM29

          I'm taking a look at the Settings component.
          Is it capable to save the settings in separate file wich I could eventually generate with an external app. What it imply is that is as a well know format such as .xml, .json or something like that ?

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @DavidM29 said in run through each components on the page:

          Is it capable to save the settings in separate file wich I could eventually generate with an external app

          Yes, see the docs:

          The information is stored in the system registry on Windows, and in XML preferences files on macOS. On other Unix systems, in the absence of a standard, INI text files are used. See QSettings documentation for more details.
          

          And this static method: QSettings::setPath().

          (Z(:^

          1 Reply Last reply
          1
          • D Offline
            D Offline
            DavidM29
            wrote on last edited by
            #5

            Thank you for your replies.

            I think Settings is not the good solution for me because I haven't been able to find a way to have controls on when the parameters are saved on the file. I want them to change and save them only when a button is pressed. I already have file reading and writing functions in C++.
            My files are a bit like java ".properties" files :

            "
            property01=value01
            property02=value02
            .
            .
            .
            propertyXX=valueXX
            "

            Regarding the loop on all my Qml element from C++ how can I access my QML component from a separate cpp file (I mean by that not from the main.cpp).

            1 Reply Last reply
            0

            • Login

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