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. A simple question: How to update multi form on mainwindows. use view and model ?
Forum Updated to NodeBB v4.3 + New Features

A simple question: How to update multi form on mainwindows. use view and model ?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 308 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.
  • X Offline
    X Offline
    Xrtero
    wrote on 3 Jul 2024, 03:02 last edited by
    #1

    for example , on following image:

    ed6eddb6-2f01-4ede-85f9-961e8195af27-image.png

    i want to update name , when server modify the user name.

    P J 2 Replies Last reply 3 Jul 2024, 04:08
    0
    • X Xrtero
      3 Jul 2024, 03:02

      for example , on following image:

      ed6eddb6-2f01-4ede-85f9-961e8195af27-image.png

      i want to update name , when server modify the user name.

      P Offline
      P Offline
      Pl45m4
      wrote on 3 Jul 2024, 04:08 last edited by Pl45m4 7 Mar 2024, 04:09
      #2

      @Xrtero

      Yes, either a model which fetches the data and updates the view or you send update manually via signal&slot to your display field.
      Depends on how much data you have, how you want to organize it and what you want to do with it.
      Implementing your own model + view just to update the first name / last name, is not worth it if you ask me.
      If you have more data and want to store multiple datasets, it's probably the cleanest and best way.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      X 1 Reply Last reply 6 Jul 2024, 02:59
      0
      • X Xrtero
        3 Jul 2024, 03:02

        for example , on following image:

        ed6eddb6-2f01-4ede-85f9-961e8195af27-image.png

        i want to update name , when server modify the user name.

        J Offline
        J Offline
        JonB
        wrote on 3 Jul 2024, 07:49 last edited by
        #3

        @Xrtero
        Consider using QDataWidgetMapper. That provides a two-way mapping between widgets and model, so changes in the model update the widget and if the user changes the widget that updates the model.

        But depends what you mean by "when server modify the user name". If "server" means database server (like MySQL) you will not get a "notification" if a different process updates a database table, that is not supported.

        X 1 Reply Last reply 6 Jul 2024, 03:12
        0
        • P Pl45m4
          3 Jul 2024, 04:08

          @Xrtero

          Yes, either a model which fetches the data and updates the view or you send update manually via signal&slot to your display field.
          Depends on how much data you have, how you want to organize it and what you want to do with it.
          Implementing your own model + view just to update the first name / last name, is not worth it if you ask me.
          If you have more data and want to store multiple datasets, it's probably the cleanest and best way.

          X Offline
          X Offline
          Xrtero
          wrote on 6 Jul 2024, 02:59 last edited by
          #4

          @Pl45m4
          thanks , i think both are ok.
          but , a model was cleanest way. i will choose according to the actual situation.

          1 Reply Last reply
          0
          • J JonB
            3 Jul 2024, 07:49

            @Xrtero
            Consider using QDataWidgetMapper. That provides a two-way mapping between widgets and model, so changes in the model update the widget and if the user changes the widget that updates the model.

            But depends what you mean by "when server modify the user name". If "server" means database server (like MySQL) you will not get a "notification" if a different process updates a database table, that is not supported.

            X Offline
            X Offline
            Xrtero
            wrote on 6 Jul 2024, 03:12 last edited by
            #5

            @JonB
            "server" means http server (like when i want get the username ,age ... etc )
            so ,as the number of labels increases, the use of signals and slots becomes progressively more complex.
            Moreover, if a single page needs to include various types of information ( i meaning different model objects),it will becomes particularly complicated . Using a model and view approach will make the core more simple(just use setModel to update view) . that's my impression as beginner.

            P X 2 Replies Last reply 6 Jul 2024, 14:53
            0
            • X Xrtero
              6 Jul 2024, 03:12

              @JonB
              "server" means http server (like when i want get the username ,age ... etc )
              so ,as the number of labels increases, the use of signals and slots becomes progressively more complex.
              Moreover, if a single page needs to include various types of information ( i meaning different model objects),it will becomes particularly complicated . Using a model and view approach will make the core more simple(just use setModel to update view) . that's my impression as beginner.

              P Offline
              P Offline
              Pl45m4
              wrote on 6 Jul 2024, 14:53 last edited by Pl45m4 7 Jun 2024, 14:54
              #6

              @Xrtero said in A simple question: How to update multi form on mainwindows. use view and model ?:

              "server" means http server (like when i want get the username ,age ... etc )

              So you make HTTP requests? With QNAM?

              as the number of labels increases, the use of signals and slots becomes progressively more complex.

              Using more signals doesn't make you app more complex, esp when they just update a string/int in a LineEdit.

              Moreover, if a single page needs to include various types of information ( i meaning different model objects),it will becomes particularly complicated

              The approach @JonB suggested is still viable. You can map these kind of information to the correct field where they are displayed.

              Using a model and view approach will make the core more simple(just use setModel to update view) .

              setModel does not update anything. It only assigns the model to the view.
              For a custom model/view there is still a lot to do (re-implement functions, handle your use-case)...

              that's my impression as beginner.

              ...might not be that easy, as a beginner :)


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              2
              • X Xrtero
                6 Jul 2024, 03:12

                @JonB
                "server" means http server (like when i want get the username ,age ... etc )
                so ,as the number of labels increases, the use of signals and slots becomes progressively more complex.
                Moreover, if a single page needs to include various types of information ( i meaning different model objects),it will becomes particularly complicated . Using a model and view approach will make the core more simple(just use setModel to update view) . that's my impression as beginner.

                X Offline
                X Offline
                Xrtero
                wrote on 9 Jul 2024, 00:16 last edited by
                #7

                @Xrtero thank your reply, i think i know what i should do.

                1 Reply Last reply
                0
                • X Xrtero has marked this topic as solved on 9 Jul 2024, 00:16

                1/7

                3 Jul 2024, 03:02

                • Login

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