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. QTreeView - Add child (append rows) on expand
Forum Updated to NodeBB v4.3 + New Features

QTreeView - Add child (append rows) on expand

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 2.3k 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.
  • K Offline
    K Offline
    kumararajas
    wrote on 27 Jan 2016, 11:55 last edited by
    #1

    Hello,

    I want to append the rows on expand. Meaning, I want to have the "+" sign enabled even if there are no rows present below. Because, I will be adding the rows on expand.

    How to achieve this?

    Thanks,
    Kumar

    --Kumar

    R 1 Reply Last reply 27 Jan 2016, 11:57
    0
    • K kumararajas
      27 Jan 2016, 11:55

      Hello,

      I want to append the rows on expand. Meaning, I want to have the "+" sign enabled even if there are no rows present below. Because, I will be adding the rows on expand.

      How to achieve this?

      Thanks,
      Kumar

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 27 Jan 2016, 11:57 last edited by
      #2

      @kumararajas
      override QAbstractItemModel::canFetchMore() and return true when there is data available for loading, false otherwise.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      K 1 Reply Last reply 27 Jan 2016, 13:30
      0
      • R raven-worx
        27 Jan 2016, 11:57

        @kumararajas
        override QAbstractItemModel::canFetchMore() and return true when there is data available for loading, false otherwise.

        K Offline
        K Offline
        kumararajas
        wrote on 27 Jan 2016, 13:30 last edited by
        #3

        @raven-worx

        It is new to me. Thanks for the thought Raven.
        But, still I am unable to get the expected results.

        I have overridden canFetchMore and return true always.

        bool MyClass::canFetchMore(const QModelIndex & parent) const
        {
            return true;
        }
        

        But, if I do not appendRow, then, I do not see the "expand" sign.

        Since I dont see the "expand" sign, I am unable to load the items.

        My goal is to load the items only on expand.

        Any thoughts?

        Thanks,
        Kumara

        --Kumar

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kumararajas
          wrote on 27 Jan 2016, 14:08 last edited by
          #4

          This is classic!

          I was doing some silly mistakes. And I was too quick to reply back.

          Later fixing my bugs, I could achieve it.

          Thank you very much Raven!

          --Kumara

          --Kumar

          R 1 Reply Last reply 27 Jan 2016, 14:48
          0
          • K kumararajas
            27 Jan 2016, 14:08

            This is classic!

            I was doing some silly mistakes. And I was too quick to reply back.

            Later fixing my bugs, I could achieve it.

            Thank you very much Raven!

            --Kumara

            R Offline
            R Offline
            raven-worx
            Moderators
            wrote on 27 Jan 2016, 14:48 last edited by raven-worx
            #5

            @kumararajas
            and btw. what i forgot to mention:
            you should load your data in the fetchMore() method of the model. IIRC this is called by the treeview on expand (when canFetchMore() returns true for this index). Maybe also in some other situations by Qt.
            Anyway it's always a good idea to follow the given API.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            K 1 Reply Last reply 29 Jan 2016, 06:08
            0
            • R raven-worx
              27 Jan 2016, 14:48

              @kumararajas
              and btw. what i forgot to mention:
              you should load your data in the fetchMore() method of the model. IIRC this is called by the treeview on expand (when canFetchMore() returns true for this index). Maybe also in some other situations by Qt.
              Anyway it's always a good idea to follow the given API.

              K Offline
              K Offline
              kumararajas
              wrote on 29 Jan 2016, 06:08 last edited by
              #6

              @raven-worx Thanks Raven! That helps me a lot..

              --Kumar

              1 Reply Last reply
              0

              1/6

              27 Jan 2016, 11:55

              • Login

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