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. Save settings in UI
Forum Updated to NodeBB v4.3 + New Features

Save settings in UI

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • G Offline
    G Offline
    gergnnud
    wrote on last edited by
    #1

    I'm a complete newbie (a noob) to QT Creator (1 week) so I'm sorry if this question is really dumb.

    I'm a visual kind of person so being able to generate a UI with QT Creator has been a joyful experience but I seem to be missing something very fundamental and cannot seem to Google an answer.

    I have all these lineEdits and checkBoxes designed as settings for the application in a popup QDialog with tabs. I can easily generate default values in Creator, which is what I want to begin with (first run) but then I want to run the app and change settings and have those settings stick.

    At present, if I enter text in a lineEdit, uncheck or check a checkbox, radio button etc. in the running app nothing is saved. When I pop the window open again everything has reverted to the defaults.

    Of course I understand I need to program something into the slots for the standard buttonBox with Cancel and Save. I see that the slot options for buttonBox is accept and reject. What do I need in the accepted slot to accept changes and override all the default values in the ui? ...and is that the way to do it or should it be generating a separate config text file.

    Sorry if this has been answered before but I just can't find anything.

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

      Hi, please take a look at "QSettings":http://qt-project.org/doc/qt-5/QSettings.html class. It can be used to remember values between application runs. If you want to remember them at runtime only (and/ or you do not want to use QSettings for some reason), then the solution is not to delete the dialog when it is accepted, only to hide it. The next time it's shown, it will still hold the same values.

      (Z(:^

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gergnnud
        wrote on last edited by
        #3

        Thanks sierdzio

        I will give QSettings a go. Seems simple enough.

        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