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. Support for QStandardItem proxies?
QtWS25 Last Chance

Support for QStandardItem proxies?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qstandarditemcustom datadata modelsproxyadapter
27 Posts 3 Posters 8.0k 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.
  • V VRonin
    5 Oct 2018, 12:29

    @elfring said in Support for QStandardItem proxies?:

    How do you think about the introduction of a class like QProxyModelIndex then?

    QAbstractPorxyModel::mapToSource/QAbstractPorxyModel::mapFromSource already do everything that class would do so I see no gain in introducing it

    Should the difference between indexes for proxy and source models be better described in the Qt documentation?

    A proxy model is still a model, the docs say "Note that it's undefined behavior to pass illegal indices to item models" so I feel it is documented already

    E Offline
    E Offline
    elfring
    wrote on 5 Oct 2018, 13:01 last edited by
    #21

    A proxy model is still a model,

    This information is generally appropriate.

    the docs say "Note that it's undefined behavior to pass illegal indices to item models"

    A constraint is mentioned.

    so I feel it is documented already

    Now I imagine that a better class design can prevent the passing of inappropriate indexes a bit more.
    How are the chances to specify that QAbstractProxyModel-like objects need to work with QProxyModelIndex objects instead?

    V 1 Reply Last reply 5 Oct 2018, 13:06
    0
    • E elfring
      5 Oct 2018, 13:01

      A proxy model is still a model,

      This information is generally appropriate.

      the docs say "Note that it's undefined behavior to pass illegal indices to item models"

      A constraint is mentioned.

      so I feel it is documented already

      Now I imagine that a better class design can prevent the passing of inappropriate indexes a bit more.
      How are the chances to specify that QAbstractProxyModel-like objects need to work with QProxyModelIndex objects instead?

      V Offline
      V Offline
      VRonin
      wrote on 5 Oct 2018, 13:06 last edited by VRonin 10 May 2018, 13:06
      #22

      @elfring said in Support for QStandardItem proxies?:

      Now I imagine that a better class design can prevent the passing of inappropriate indexes a bit more.

      Agree that's why I said:

      I'm surprised it didn't just assert.

      How are the chances to specify that QAbstractProxyModel-like objects need to work with QProxyModelIndex objects instead?

      1. QAbstractProxyModel is a subclass of QAbstractItemModel and the view should not care whether the model it's attached to is a proxy or not

      "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

      E 1 Reply Last reply 5 Oct 2018, 13:15
      2
      • V VRonin
        5 Oct 2018, 13:06

        @elfring said in Support for QStandardItem proxies?:

        Now I imagine that a better class design can prevent the passing of inappropriate indexes a bit more.

        Agree that's why I said:

        I'm surprised it didn't just assert.

        How are the chances to specify that QAbstractProxyModel-like objects need to work with QProxyModelIndex objects instead?

        1. QAbstractProxyModel is a subclass of QAbstractItemModel and the view should not care whether the model it's attached to is a proxy or not
        E Offline
        E Offline
        elfring
        wrote on 5 Oct 2018, 13:15 last edited by
        #23

        the view should not care whether the model it's attached to is a proxy or not

        Can overloaded functions (from a specific proxy class) help any more to detect questionable indexes?

        V 1 Reply Last reply 5 Oct 2018, 14:12
        0
        • E elfring
          5 Oct 2018, 13:15

          the view should not care whether the model it's attached to is a proxy or not

          Can overloaded functions (from a specific proxy class) help any more to detect questionable indexes?

          V Offline
          V Offline
          VRonin
          wrote on 5 Oct 2018, 14:12 last edited by
          #24

          @elfring said in Support for QStandardItem proxies?:

          Can overloaded functions (from a specific proxy class) help any more to detect questionable indexes?

          It can help but there's no bullet proof solution.

          In the meantime I submitted a change to QStandardItemModel that would have made your bug assert in debug

          "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

          E C 2 Replies Last reply 5 Oct 2018, 14:23
          1
          • V VRonin
            5 Oct 2018, 14:12

            @elfring said in Support for QStandardItem proxies?:

            Can overloaded functions (from a specific proxy class) help any more to detect questionable indexes?

            It can help but there's no bullet proof solution.

            In the meantime I submitted a change to QStandardItemModel that would have made your bug assert in debug

            E Offline
            E Offline
            elfring
            wrote on 5 Oct 2018, 14:23 last edited by
            #25

            In the meantime I submitted a change to QStandardItemModel that would have made your bug assert in debug

            I find it interesting that my clarification request triggered such a software evolution finally.
            Would you like to continue the development discussion also around proxies for QStandardItem (or eventually other classes)?

            1 Reply Last reply
            0
            • V VRonin
              5 Oct 2018, 14:12

              @elfring said in Support for QStandardItem proxies?:

              Can overloaded functions (from a specific proxy class) help any more to detect questionable indexes?

              It can help but there's no bullet proof solution.

              In the meantime I submitted a change to QStandardItemModel that would have made your bug assert in debug

              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 5 Oct 2018, 15:06 last edited by
              #26

              @VRonin said in Support for QStandardItem proxies?:

              assert in debug

              But only when Qt was compiled in debug mode which is for sure not the case...

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              V 1 Reply Last reply 5 Oct 2018, 15:24
              0
              • C Christian Ehrlicher
                5 Oct 2018, 15:06

                @VRonin said in Support for QStandardItem proxies?:

                assert in debug

                But only when Qt was compiled in debug mode which is for sure not the case...

                V Offline
                V Offline
                VRonin
                wrote on 5 Oct 2018, 15:24 last edited by
                #27

                @Christian-Ehrlicher said in Support for QStandardItem proxies?:

                But only when Qt was compiled in debug mode

                Yes, as the docs say using invalid indexes remains undefined behaviour, I am just trying to help users spot these cases

                "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

                21/27

                5 Oct 2018, 13:01

                • Login

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