<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,<br>
    </p>
    <div class="moz-cite-prefix">On 17/05/2022 17:44, Arno Rehn wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:a814d7ee-2a97-7a41-e6c1-bb3d84fa8420@menlosystems.com"><br>
      Am 17.05.2022 um 17:36 schrieb Konrad Rosenbaum:
      <br>
      <blockquote type="cite">On 17/05/2022 14:58, Volker Hilsheimer
        wrote:
        <br>
        <blockquote type="cite">As mentioned in the JIRA ticket: perhaps
          a treeview, which is designed to show rows of data, not cells
          of data, is not the right UI component for the job, and the
          problem you try to solve seems very application specific (I’m
          not aware of a native tree view on macOS or Windows that
          provides a strong visual border between columns; ie macOS’s
          folder has a specific Column view mode for that). Override the
          delegate and make each cell stand out more if you want, or
          override the view’s paintEvent and render whatever you want
          after the view is done. I don’t think this belongs into
          QTreeView. </blockquote>
        <br>
        <br>
        It is a really common requirement - if you have complex
        hierarchical models then sometimes you have no choice but to
        display parts of the hierarchy in a table. Unfortunately
        QTableView is not able to view trees and QTreeView is
        sub-optimal for viewing tables. What is required is a widget or
        mode of a widget that combines both abilities. I've had this
        requirement in almost all of my projects that try to visualize
        and interact with complex data analyses.
        <br>
      </blockquote>
      <br>
      Sounds like QTableView is really what you want, but your model is
      not a table model. You can implement a proxy model that exposes a
      subtree of your tree model (possibly also hiding any remaining
      children). This subtree should be usable with QTableView just
      fine.
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>For my application showing a sub-tree only would probably be the
      worst I could do. Each subtree would be a tiny tiny fraction of
      the data I need to show in a really nice overview of data that
      absolutely needs additional columns. The original model is handled
      just fine by a tree view, it just is extremely difficult to read
      with the spacial compression of a normal tree view.</p>
    <p>Tree views seem to be optimized for simple tree models like file
      system hierarchies that you would want to display in a compressed
      manner, because the data is usually very uniform and pre-sorted.
      If you have hierarchical data that requires more "breathing room"
      for the user to not get lost, then you are faced with overriding
      the view, style or delegate.<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:a814d7ee-2a97-7a41-e6c1-bb3d84fa8420@menlosystems.com">
      I've implemented such a SubtreeProxyModel for our own needs and it
      works nicely (it's not primarily used for QTableView, though).
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>I ended up deriving from QStyledItemDelegate and adding frames to
      each cell in my QTreeView. It works good enough for that
      application, but in my opinion it is Upper Case Ugly. And it took
      a lot of unnecessary experimentation to arrive at that:</p>
    <p><img src="cid:part1.VY9LLh1T.sdAeRzyj@silmor.de" alt=""></p>
    <p>(in this particular case this table has 48 top level rows with an
      average of 4 sub-rows)<br>
    </p>
    <p>The hierarchy edited in this program is huge - this is only a
      very small fraction of it. If I was forced to further sub-divide
      these tree tables into multiple widgets than the program would go
      from "hard to use" to basically "worse than editing the XML file
      in vi".</p>
    <p><br>
    </p>
    <p>The code I wrote is this:<br>
<a class="moz-txt-link-freetext" href="https://phabricator.silmor.de/source/Chipper/browse/master/widgets/griddelegate.h">https://phabricator.silmor.de/source/Chipper/browse/master/widgets/griddelegate.h</a><br>
<a class="moz-txt-link-freetext" href="https://phabricator.silmor.de/source/Chipper/browse/master/widgets/griddelegate.cpp">https://phabricator.silmor.de/source/Chipper/browse/master/widgets/griddelegate.cpp</a></p>
    <p>I'm not happy to have the frames hard coded instead of styled,
      but I would be even less happy spending even more time on this.</p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p>    Konrad<br>
    </p>
  </body>
</html>