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. Signal flag changes for QAbstractItemModel
Forum Updated to NodeBB v4.3 + New Features

Signal flag changes for QAbstractItemModel

Scheduled Pinned Locked Moved Unsolved General and Desktop
itemmodel
18 Posts 4 Posters 3.8k Views 2 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.
  • SGaistS SGaist

    @JonB maybe coupled with EditRole since the flag change might also influence that part.

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

    @SGaist Do a dataChanged() for "all roles" and then you have done the best you can :)

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

      I am sure there are some corner cases that will be fun

      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
      • kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #11

        Well, I'd long forgotten about this topic, but I would think we actually need a flagsChanged(QModelIndex, QModelIndex) signal, which would be "the right way"™. I didn't open a feature request at the time, but maybe one of you might feel strongly enough about it to do so.

        Read and abide by the Qt Code of Conduct

        JonBJ 1 Reply Last reply
        1
        • kshegunovK kshegunov

          Well, I'd long forgotten about this topic, but I would think we actually need a flagsChanged(QModelIndex, QModelIndex) signal, which would be "the right way"™. I didn't open a feature request at the time, but maybe one of you might feel strongly enough about it to do so.

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

          @kshegunov
          It would indeed! But then the issue is: who wants to go through all the code finding every occurrence where flags() has changed to decide what needs to be done in response? And in practice would it be any more or less than dataChanged(index, index, {}) does? :)

          kshegunovK 1 Reply Last reply
          0
          • JonBJ JonB

            @kshegunov
            It would indeed! But then the issue is: who wants to go through all the code finding every occurrence where flags() has changed to decide what needs to be done in response? And in practice would it be any more or less than dataChanged(index, index, {}) does? :)

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #13

            @JonB said in Signal flag changes for QAbstractItemModel:

            It would indeed! But then the issue is: who wants to go through all the code finding every occurrence where flags() has changed to decide what needs to be done in response?

            It should be painless in the sense that it's a new signal, so nobody needs to actually do anything to keep old code working.

            And in practice would it be any more or less than dataChanged(index, index, {}) does? :)

            Possibly, as you don't go around querying the data from the model, albeit I'm not sure if that's really relevant, as in the end you may need to.

            Read and abide by the Qt Code of Conduct

            JonBJ 1 Reply Last reply
            0
            • kshegunovK kshegunov

              @JonB said in Signal flag changes for QAbstractItemModel:

              It would indeed! But then the issue is: who wants to go through all the code finding every occurrence where flags() has changed to decide what needs to be done in response?

              It should be painless in the sense that it's a new signal, so nobody needs to actually do anything to keep old code working.

              And in practice would it be any more or less than dataChanged(index, index, {}) does? :)

              Possibly, as you don't go around querying the data from the model, albeit I'm not sure if that's really relevant, as in the end you may need to.

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

              @kshegunov said in Signal flag changes for QAbstractItemModel:

              Possibly, as you don't go around querying the data from the model, albeit I'm not sure if that's really relevant, as in the end you may need to.

              Because of, say, Qt::ItemIsEnabled flag, which shows item differently, won't it end up having to access item's DisplayRole which has to query the model to get the text again to show it dimmed?

              kshegunovK 1 Reply Last reply
              0
              • JonBJ JonB

                @kshegunov said in Signal flag changes for QAbstractItemModel:

                Possibly, as you don't go around querying the data from the model, albeit I'm not sure if that's really relevant, as in the end you may need to.

                Because of, say, Qt::ItemIsEnabled flag, which shows item differently, won't it end up having to access item's DisplayRole which has to query the model to get the text again to show it dimmed?

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #15

                @JonB said in Signal flag changes for QAbstractItemModel:

                Because of, say, Qt::ItemIsEnabled flag, which shows item differently, won't it end up having to access item's DisplayRole which has to query the model to get the text again to show it dimmed?

                It may, which was my original argument - it (the signal) could simply do nothing significant in the end.

                Read and abide by the Qt Code of Conduct

                SGaistS 1 Reply Last reply
                0
                • kshegunovK kshegunov

                  @JonB said in Signal flag changes for QAbstractItemModel:

                  Because of, say, Qt::ItemIsEnabled flag, which shows item differently, won't it end up having to access item's DisplayRole which has to query the model to get the text again to show it dimmed?

                  It may, which was my original argument - it (the signal) could simply do nothing significant in the end.

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #16

                  I wonder how often this use case happens.

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

                  kshegunovK 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    I wonder how often this use case happens.

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #17

                    @SGaist said in Signal flag changes for QAbstractItemModel:

                    I wonder how often this use case happens.

                    I'd imagine for any nontrivial use of the item model, this will happen. In the case of widgets it probably won't matter anyway, as you'd want to immediately redraw whatever it is you're showing; but with Qt quick it may actually be a malice on performance, since it would invalidate the scene graph node (which may or may not be a problem, I haven't actually looked at the implementation).

                    Read and abide by the Qt Code of Conduct

                    JonBJ 1 Reply Last reply
                    0
                    • kshegunovK kshegunov

                      @SGaist said in Signal flag changes for QAbstractItemModel:

                      I wonder how often this use case happens.

                      I'd imagine for any nontrivial use of the item model, this will happen. In the case of widgets it probably won't matter anyway, as you'd want to immediately redraw whatever it is you're showing; but with Qt quick it may actually be a malice on performance, since it would invalidate the scene graph node (which may or may not be a problem, I haven't actually looked at the implementation).

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

                      @kshegunov
                      One might actually need the signal to tell us which flags have changed. Only certain flag changes affect anything we are interested in, several seem not relevant.

                      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