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. [SOLVED] Tablemodel dataChanged problem
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Tablemodel dataChanged problem

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 3.9k 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.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #2

    The screenshot can't be seen, also not from the link you provided: access denied.

    You cannot and should not avoid that from happening. Why do you want to stop it from happening? Anyway, it sounds like you are trying to re-implement "CheckableProxyModel":/wiki/QSortFilterProxyModel_subclass_to_add_a_checkbox ...

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zarkon
      wrote on last edited by
      #3

      The link I just repaired. I was not aware of CheckableProxyModel. I will check it out.

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

        [quote author="Zarkon" date="1400054490"]The link I just repaired.[/quote]

        Quote: no, you did not. It still says 403 access denied. Problem is: you probably can't see that, as you do have access. I usually use dropbox to host images I want to put on the forum...

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          Zarkon
          wrote on last edited by
          #5

          Dropbox is not allowed in this company. I have use my own site. And also there I had to implement a lot of security because it is under constant attack by zombies. Second try. I hope it shows because I dont think CheckableProxyModel is the answer.

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

            [quote]403 - Permission Denied

            You been messing around and that was noticed, <my ip> has been banned.[/quote]

            If clicking a link to a picture you posted is "messing around", your security measures may be a bit too strict..

            Is imgbin.org allowed for you?

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              Zarkon
              wrote on last edited by
              #7

              Used my photo album site now. It should be ok. For safety better remove your ip-address.

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

                It seems like a rather complicated setup. Why are you using two views, instead of one? I would have simply added a couple of columns to my tree view model and not worry about any syncing between models...

                Anyway, the picture is more clear now. I think you do need something like what CheckableProxyModel does, but not exactly. Where this proxy model only keeps track of one checked state per row in the source model, you need to keep track of five that you put in different columns. Your benefit: you don't have a deep hierarchy.

                I still don't get what the actual problem is you are trying to solve? As I asked before:
                [quote author="Andre" date="1400054152"]You cannot and should not avoid that from happening. Why do you want to stop it from happening? [/quote]

                Are you seeing recursive calls to your update code perhaps?

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  Zarkon
                  wrote on last edited by
                  #9

                  The recursive calls are the problem.

                  The thing is when I set the parent row to checked it sets the children to checked (1). So far fine. But the children generate also a "data changed" event. They update the parent when procedure (2) is enabled. This kinds of locks both the parent and the children.

                  Also if I check the children one by one (2-repeatedly) the parent updates nicely (gets checked when all children are checked). However combined with (1) the children cannot be set to checked or when unchecked, uncheck all children.

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

                    It is a matter of making sure that you only emit the data changed event if you actually set new data. Or, if you use QStandardItemModel, only set a state if the state really is different from the previous state. You can of course also block your handling of the recursive calls using a simple flag or something like that.

                    I basically had the same problem when writing CheckableProxyModel. I used a more complicated solution there. The solution I implemented was something along these lines: Instead of having three states (Checked, Unchecked, Partial), you have four (Checked, Unchecked, DeterminedByParent, DeterminedByChildren). The DeteriminedBy... states evaluate to checked or unchecked or partial, depending on the state of items.

                    For leaf items, the default value is DeterminedByParent. If an item gets and explicit state, it's siblings will also get an explicit state (that of the parent), and the parent goes to DeterminedByChildren. I think I had a process that in the background simplified the tree when possible (make sure that if all children of a parent have the same state, they all get the DeterminedByParent state again and the parent gets the explicit state instead).

                    As I was working with having to keep track of the checked state separately from the data itself, and the tree would potentially be huge and not even completely loaded (like with QFileSystemModel), that worked to keep a small and efficient data structure.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      Zarkon
                      wrote on last edited by
                      #11

                      I put the whole procedure now in the on click event of the tableview. That creates some overhead when you click beside the checkbox (state does not change), but looping is now prevented.

                      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