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. Adding data to Frozen Column QTreeWidget
Forum Updated to NodeBB v4.3 + New Features

Adding data to Frozen Column QTreeWidget

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • A Offline
    A Offline
    ajaxcrypto
    wrote on last edited by
    #1

    I have created a frozen column QTreeWidget (first column is not scrollable), by sharing model with a QTreeView and using viewport->stackUnder .

    1. Any child row is to be added only when parent is expanded. This works fine for the frozen QTreeView, but any data in other columns do not get displayed in the underlying QTreeWidget, so all other columns are blank for child rows. (Verified that the child QTreeWidgetItem does contain the data for other columns)

    2. The data added does not get displayed in-order in the widget i.e. even though I insert with QTreeWidget::addTopLevelItem in a loop, the actual output does not match the order in which the items are added.

    What is the correct way of writing this? Also, I tried using QTreeView and QAbstractItemModel but that further complicates the model and could not get it working. Is writing a dedicated model the only way?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ajaxcrypto
      wrote on last edited by
      #2

      Never mind, I solved both of the problems.

      1. Issue was with hooking up event handlers and from where child items were being populated.
      2. Default sorting was enabled, which was leading to this.
      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        So you made something like
        http://doc.qt.io/qt-5/qtwidgets-itemviews-frozencolumn-example.html

        With tree views ?

        Good work :)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ajaxcrypto
          wrote on last edited by
          #4

          Yes inspired from that example, though some modification specific to QTreeView, but everything now works except for few hiccups regarding child row visibility. Posted a separate question.

          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