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. [Code Design] Config dialog
Forum Updated to NodeBB v4.3 + New Features

[Code Design] Config dialog

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.4k 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.
  • VinorcolaV Offline
    VinorcolaV Offline
    Vinorcola
    wrote on last edited by
    #1

    Hi everybody,

    I've created a custom model that holds some configurations. I would like to create a dialog to edit this model. So I've used a QDataWidgetMapper in the dialog to do so. It works well, but every modifications are directly done in the model, and I'd like now that the modifications are apply on the model only when the user click on "OK" or "Apply", but not on "Cancel" button.

    I know the QDataWidgetMapper has a submit policy, but this apply for a column in the model. I'd like all the modifications (on all columns) to be apply at the same time (when user confirm).

    What is the best way to do that? I thought I could create a copy of the model, and edit this copy in the dialog. If the user cancel, I just drop the copied model. If the user confirm, I replace the original model by the copy. But I find this solution heavy as I copy the whole model in order to maybe modify 2 or 3 things into it.

    So if you'd like to share some tips on the best way to do that, I thank you.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      QDataWidgetMapper applies the submit policy to all fields handled by it so unless you create one mapper per widget, your use case is already covered

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • VinorcolaV Offline
        VinorcolaV Offline
        Vinorcola
        wrote on last edited by
        #3

        The QDataWidget handled all the "rows" of a column in my model (which is a table model). But it can't handle all the columns at the same time. It manages one column a the time right?

        I want the user to be abble to edit the whole model and confirm afterwards. The QDataWidget allows me to edit only one column at the time.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No, you're wrong. When you call addMapping, you're giving a widget and a section. The section is a model column.

          From there you can navigate from one row to another.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • VinorcolaV Offline
            VinorcolaV Offline
            Vinorcola
            wrote on last edited by
            #5

            Yes ok, but it doesn't change the problem: how to keep all the row modification in memory until the user confirm the changes?

            NOTE: You can change the sens QDataWidgetMapper works withQDataWidgetMapper::setOrientation()

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Right, forgot your setOrientation (not the most common use case)

              I might be wrong, bug IIRC, QDataWidgetMapper uses a model internally so it's could be already done for you.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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