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. How to incrementally add children to QTreeWidget

How to incrementally add children to QTreeWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 810 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    HI
    I have a QtreeWidget , that viewport shows and it has 10 root nodes
    I have a incrementally add the children , means if I have 10 roots nodes

    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    and When I expand A root nodes ,

    1. How to calculate how many children I can see, in current display
    2. Also add only those many children which the user can see
    3. When we move the vertical scrollbar or resize then we only add incrementally children which are not added

    Can someone give the hint

    JonBJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      HI
      I have a QtreeWidget , that viewport shows and it has 10 root nodes
      I have a incrementally add the children , means if I have 10 roots nodes

      A
      B
      C
      D
      E
      F
      G
      H
      I
      J
      and When I expand A root nodes ,

      1. How to calculate how many children I can see, in current display
      2. Also add only those many children which the user can see
      3. When we move the vertical scrollbar or resize then we only add incrementally children which are not added

      Can someone give the hint

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

      @Qt-Enthusiast
      I will just say: in order to see which items are visible, https://stackoverflow.com/questions/28829192/how-to-get-the-number-of-items-of-a-qtreewidget answers claim that QTreeWidgetItem::isExpanded() will tell you that for each item. Frankly I'm dubious, as I would have thought that would only tell you about expansion not visibility, but you could test. I do not see anything in QTreeWidgetItem to tell you about size/visibility (they are not QWidgets, unfortunately), so that's problematic.

      maybe you will get a better answer from an expert....

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        What's the reason not adding the items at all on startup trying some crude stuff instead?

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

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          performance

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Then you should not use a convenience widget but a proper model with a QTreeView ...

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

            1 Reply Last reply
            1
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on last edited by
              #6

              that is not possible because of legacy code

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                lol
                On the one side you say you're adding items by yourself to the QTreeWidget and want to modify this behavior in really strange ways, on the other side you tell us that you can't replace exactly the QTreeWidget with a QTreeView and build a proper model ...

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

                1 Reply Last reply
                1

                • Login

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