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. Connect two forms to edit data

Connect two forms to edit data

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 397 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.
  • R Offline
    R Offline
    russjohn834
    wrote on last edited by
    #1

    Hi all,

    I have form having tabwidget to save data as xml file.

    I'm looking forward to implement option to modify data.

    I have a button modify, when clicked user get a dialogue box to open data. Once an entry selected I can get contents.

    Now I need to pass these contents to the same tabwidget for user to edit. Can you suggest me best way to do this?

    Thanks in advance

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Are you sure it's a QTabWidget? sounds odd...

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • R Offline
        R Offline
        russjohn834
        wrote on last edited by russjohn834
        #3

        @VRonin sorry about my vague explanation. I mean there is QTabWidget having many fields to (lineedit, dateTimeEdit , textEdit etc., find screenshot attached) to gather data.tabwidget.JPG ) to collect data

        JonBJ 1 Reply Last reply
        0
        • R russjohn834

          @VRonin sorry about my vague explanation. I mean there is QTabWidget having many fields to (lineedit, dateTimeEdit , textEdit etc., find screenshot attached) to gather data.tabwidget.JPG ) to collect data

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @russjohn834
          So assuming you mean you populate those widgets with what you read from the XML, you will allow the user to edit the content of those widgets and then regenerate the complete new XML (either from scratch, or by modifying the in-memory QDomDocument if you are using that) to save back to file. I don't see any (need for) "Connect two forms to edit data"....

          1 Reply Last reply
          2
          • R Offline
            R Offline
            russjohn834
            wrote on last edited by
            #5

            @JonB Thank you. My doubt do I need two identical forms to save and modify?
            At present im presenting user following form for new entry, modify or remove.
            patient.JPG

            When modify clicked, user get a dialogue box to open already existing entries. Then the user will be presented with the same tabwidget based form with default values from the read entry.

            JonBJ 1 Reply Last reply
            0
            • R russjohn834

              @JonB Thank you. My doubt do I need two identical forms to save and modify?
              At present im presenting user following form for new entry, modify or remove.
              patient.JPG

              When modify clicked, user get a dialogue box to open already existing entries. Then the user will be presented with the same tabwidget based form with default values from the read entry.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @russjohn834
              Well, there is no one "right" answer to this. Personally I have found over the years that I don't want to duplicate code or maintain too many forms, so I tend to do it all on one page. I don't know what others might suggest, but:

              • Page has form showing record details. Optionally some kind of "navigation", to choose what to read in. May be "master/detail", e.g. (filterable) list/table at top/side to choose which record to read in, clicking record populates form at bottom, or something like that. If you require navigation.

              • Buttons at bottom for actions.

              • For existing record, Update (after edits) and Delete. Optionally, an Edit button to go into edit mode, if you prefer not to allow user to edit automatically.

              • Button New clears out all fields, populating with any defaults for a new record. After this, an Add button does the add of newly typed in stuff.

              • Optionally, Copy on existing record, which effectively does a New followed by copying whatever from existing record to new record, leaving user to edit/press Add.

              • Optionally, Cancel, reverts any pending edits if user does not want to Update/Add.

              • No separate dialog to add/update/delete records. Hence no "Connect two forms to edit data".

              But it's up to you!

              I will just add that Qt has a nice https://doc.qt.io/qt-5/qdatawidgetmapper.html to map a data model to widgets, to save you the effort. However, this does require a QAbstractItemModel derivation, and I'm not sure you want to go down that route for where you are with your XML file. (Possibly see https://doc.qt.io/qt-5/qtwidgets-itemviews-simpledommodel-example.html, but I'm still thinking this will be too hard/unsuitable for you.)

              R 1 Reply Last reply
              0
              • JonBJ JonB

                @russjohn834
                Well, there is no one "right" answer to this. Personally I have found over the years that I don't want to duplicate code or maintain too many forms, so I tend to do it all on one page. I don't know what others might suggest, but:

                • Page has form showing record details. Optionally some kind of "navigation", to choose what to read in. May be "master/detail", e.g. (filterable) list/table at top/side to choose which record to read in, clicking record populates form at bottom, or something like that. If you require navigation.

                • Buttons at bottom for actions.

                • For existing record, Update (after edits) and Delete. Optionally, an Edit button to go into edit mode, if you prefer not to allow user to edit automatically.

                • Button New clears out all fields, populating with any defaults for a new record. After this, an Add button does the add of newly typed in stuff.

                • Optionally, Copy on existing record, which effectively does a New followed by copying whatever from existing record to new record, leaving user to edit/press Add.

                • Optionally, Cancel, reverts any pending edits if user does not want to Update/Add.

                • No separate dialog to add/update/delete records. Hence no "Connect two forms to edit data".

                But it's up to you!

                I will just add that Qt has a nice https://doc.qt.io/qt-5/qdatawidgetmapper.html to map a data model to widgets, to save you the effort. However, this does require a QAbstractItemModel derivation, and I'm not sure you want to go down that route for where you are with your XML file. (Possibly see https://doc.qt.io/qt-5/qtwidgets-itemviews-simpledommodel-example.html, but I'm still thinking this will be too hard/unsuitable for you.)

                R Offline
                R Offline
                russjohn834
                wrote on last edited by russjohn834
                #7

                @JonB Many thanks. That gives me plenty of thoughts! I had a rethink. The basic idea as follows:
                patient_new.JPG

                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