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. Keeping track of user Preferences

Keeping track of user Preferences

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 7 Posters 9.5k 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.
  • C Offline
    C Offline
    Cezary Tomczak
    wrote on last edited by
    #2

    See QSettings object: http://doc.qt.nokia.com/4.7/qsettings.html

    "The QSettings class provides persistent platform-independent application settings ... This information is often stored in the system registry on Windows, and in XML preferences files on Mac OS X."

    You can also keep the settings in your application directory using .ini file, see ::setPath():

    QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, qApp.applicationDirPath() + "/");

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kyleplattner
      wrote on last edited by
      #3

      Can I use these QT commands directly alongside my QML? Sorry if this exposes my ignorance.

      Kyle

      1 Reply Last reply
      0
      • A Offline
        A Offline
        anselmolsm
        wrote on last edited by
        #4

        [quote author="kyleplattner" date="1290476695"]Can I use these QT commands directly alongside my QML?[/quote]

        It is possible. You find more information about it in "this part of the docs":http://doc.qt.nokia.com/4.7/qtbinding.html#calling-c-methods-from-qml

        [quote author="kyleplattner" date="1290476695"]
        Sorry if this exposes my ignorance.[/quote]

        Don't need to say that, DevNet is a place to learn and share knowledge. Follow the doc I posted above and ask here if you have any problem. :-)

        Anselmo L. S. Melo (anselmolsm)

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

          Is there no way to store settings (ala QSettings) without resorting to C++? I want my app to be completely portable - ie without recompiling - and so want to do it all in QML. I've so far managed to do this for the main functionality of my app, and it would seem stupid to introduce C++ just for settings.

          ...or should I be looking to use PySide instead?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #6

            When working with QML, I would go with one of these options:

            the "data storage":http://doc.qt.nokia.com/4.7/qdeclarativeglobalobject.html#offline-storage-api facility that is in there by default

            create a custom QObject (in C++) that has properties for the settings you wish to store, and use QSettings in that object to store them. You can export the an instance of this object to your QML context.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              davidmaxwaterman
              wrote on last edited by
              #7

              ok, thanks. I was really hoping for something like QSettings - it's really simple - but I guess the data storage is good enough.

              I really want to avoid C++ since I've done the rest of my app in QML and don't want to have to build for multiple platforms just to get QSettings.

              I did some Android development, and I used qml for the settings there, so I guess it is an acceptable solution. It's a little irritating not to have QSettings, but anyway...

              Thanks.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #8

                Well, it seems like a useful suggestion to me to add such an Element to QML. Why don't you file a suggestion in "Jira":http://bugreports.qt.nokia.com for it?

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  davidmaxwaterman
                  wrote on last edited by
                  #9

                  ok, I will look into that (I kind of expect it will already be there, but anyway)...

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    davidmaxwaterman
                    wrote on last edited by
                    #10

                    http://bugreports.qt.nokia.com/browse/QTBUG-20116

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      saviosebs
                      wrote on last edited by
                      #11

                      Hi can any one please provide me with some example using QSettings with c++ and QML
                      Thanks

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        pnoffke
                        wrote on last edited by
                        #12

                        I am also looking for a good example, or the Qt-recommended way, of getting settings into a QML app with a C++ back-end. The settings will have to be passed to the C++ code (or better, read directly from the C++ code -- like you can do with "sprinkling" QSettings everywhere for different classes that read the same settings -- which saves the need for passing settings as parameters), and read and edited (through forms) with QML code.

                        I found this, which is a start, but I'd like to hear if there are better ways.
                        http://www.qtforum.org/article/37189/qml-and-c-binding.html

                        Thanks,
                        Patrick

                        Patrick

                        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